/*  Andreas RP
	By:
	ArmyOfTwo
	Andre
*/

#pragma tabsize 0 // Make sure Loose indentation warnings doesn't show up, but we will try to keep the code readable.

#define VERSION "0.1 - In development" // Define your version here.

#define DEBUG // Undefine if you don't need mysql_logs

#include <a_samp>  // ??
#include <foreach> // By Y_Less
#include <zcmd> // By Zeex
// SSCANF plugin by Y_Less

#undef INVALID_TEXT_DRAW
#define INVALID_TEXT_DRAW       Text:0xFFFF //

#include "rp-streamer.pwn" // Incognoto's
#include "rp-defines.pwn"
#include "rp-commands.pwn"
#include "rp-functions.pwn"
#include "rp-zones.pwn"

/*       SYSTEMS           		*/
#include "systems/houses.txt"
#include "systems/buildings.txt"
#include "systems/business.txt"
#include "systems/laptop.txt"
#include "systems/factions.txt"



#include <j_inventory_v2> // Inventory by Joe_Staff

main()
{
	print("\n\n\n\n\n\n\n\n");
	print(" Andreas Roleplay (version " #VERSION ")");
	print("\n\n\n\n\n\n\n\n");
}

public OnPlayerText(playerid, text[])
{

	   if(GetPVarInt(playerid, "ON_PHONE") == 1)
	   {
		 new id = GetPVarInt(playerid, "CALLING_TO");
         GetPlayerName(playerid, PlayerName, 24);
         format(str, sizeof(str), "%s (cellphone): %s", PlayerName, text );
         SendClientMessage(id, COLOR_WHITE, str);
         GetPlayerName(playerid, PlayerName, 24);
         format(str, sizeof(str), "%s (cellphone): %s", PlayerName, text );
         SendClientMessage(playerid, COLOR_WHITE, str);
         format(str, sizeof(str), "{E0E0E0}%s says(cellphone): %s", PlayerName, text );
         SendLocalMessage(playerid, str, 10.0, COLOR_WHITE);
         return false;
	   }

	   GetPlayerName(playerid, PlayerName, 24);
       format(str, sizeof(str), "%s says: %s", PlayerName, text );
       SendLocalMessage(playerid, str, 15.0, COLOR_WHITE);
	   return false;
}

public OnGameModeInit()
{
	new g_str[32];
	format(g_str, 30, "A:RP (%s)", #VERSION);
	SetGameModeText(g_str);
	SetWeather(2);

	#if defined DEBUG
    mysql_debug(1);
	#endif

	print("Connecting to the database...");
    mysql_connect(SERVER_HOST, SERVER_USER, SERVER_DB, SERVER_PASSWORD);
	if(mysql_ping() == -1)
	{
	    print("Connecting to the MySQL server failed.\nPlease check the database settings in rp-defines.pwn!");
		SendRconCommand("exit");
		return false;
	}
	LoadVehicles();
	LoadTextDraws();
	LoadBuildings();
	LoadFactions();
    ManualVehicleEngineAndLights();
    ShowNameTags(0);
    DisableInteriorEnterExits();
    LoadExits();
	LoadHouses();
	LoadBusinesses();
    LimitGlobalChatRadius(15.0);
    SetTimer("MILSEC", 100, 1);
    SetTimer("ONESEC", 3000, 1); // 3k milsec
    SetTimer("ONEMIN", 60000, 1);
    SetTimer("UpdateTIP", 9000, 1);
	return true;
}

public OnGameModeExit()
{
	mysql_close();
	return 1;
}

public OnPlayerConnect(playerid)
{

}

public OnPlayerDisconnect(playerid)
{
	gHasCharacters{playerid} = false;
	KillTimer(logscr[playerid]);
	if(PlayerInfo[playerid][cRented] != 0)
	{
		 VehicleInfo[PlayerInfo[playerid][cRented]][vRented] = -1;
	}
	if(GetPVarInt(playerid, "ON_PHONE") == 1)
	{
		new id = GetPVarInt(playerid, "CALLING_TO");
		SendClientMessage(id, COLOR_GREY, "They hangup the call");
	}
    if(GetPVarInt(playerid, "CALLING_TO") > -1)
	{
		SetPVarInt(playerid, "CALLING_TO", -1);
		SetPVarInt(playerid, "ON_PHONE", 0);
	}
    
    if(InfoBar[playerid] != Text:INVALID_TEXT_DRAW)
    {
		 TextDrawDestroy(InfoBar[playerid]);
	}
    if(InfoText[playerid] != Text:INVALID_TEXT_DRAW)
    {
		 TextDrawDestroy(InfoText[playerid]);
	}
    if(Textdraw0[playerid] != Text:INVALID_TEXT_DRAW)
    {
		 TextDrawDestroy(Textdraw0[playerid]);
	}
    if(Textdraw1[playerid] != Text:INVALID_TEXT_DRAW)
    {
		 TextDrawDestroy(Textdraw1[playerid]);
	}
    if(Textdraw2[playerid] != Text:INVALID_TEXT_DRAW)
    {
		 TextDrawDestroy(Textdraw2[playerid]);
	}
    if(Textdraw3[playerid] != Text:INVALID_TEXT_DRAW)
    {
		 TextDrawDestroy(Textdraw3[playerid]);
	}
    if(Textdraw4[playerid] != Text:INVALID_TEXT_DRAW)
    {
		 TextDrawDestroy(Textdraw4[playerid]);
	}
    if(Textdraw5[playerid] != Text:INVALID_TEXT_DRAW)
    {
		 TextDrawDestroy(Textdraw5[playerid]);
	}
    if(SpeedHud[playerid] != Text:INVALID_TEXT_DRAW)
    {
		 TextDrawDestroy(SpeedHud[playerid]);
	}
    if(VehName[playerid] != Text:INVALID_TEXT_DRAW)
    {
		 TextDrawDestroy(VehName[playerid]);
	}
    if(HouseTitle[playerid] != Text:INVALID_TEXT_DRAW)
    {
		 TextDrawDestroy(HouseTitle[playerid]);
	}
    if(HouseMenu[playerid] != Text:INVALID_TEXT_DRAW)
    {
		 TextDrawDestroy(HouseMenu[playerid]);
	}
	
	PlayerInfo[playerid][pSQLID] = 0;
	PlayerInfo[playerid][cSQLID] = 0;
	PlayerInfo[playerid][cRented] = -1;
	PlayerInfo[playerid][pRank] = 0;
	PlayerInfo[playerid][pFaction] = 0;
	PlayerInfo[playerid][pPay] = 0;
	PlayerInfo[playerid][pPaycheck] = 0;
	PlayerInfo[playerid][pNumber] = 0;
	PlayerInfo[playerid][pRadio] = 0;

    SaveInventory(playerid);
}

public OnPlayerRequestClass(playerid, classid)
{
	if(!gHasCharacters{playerid})
	{
		ClearChat(playerid);
        TogglePlayerSpectating(playerid, true);
		GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
		format(query, sizeof(query), "SELECT * FROM accounts WHERE name = '%s'", PlayerName);
		mysql_query(query, LOGIN_MENU, playerid);
        Camera[playerid] = -1161.6046;
        logscr[playerid] = SetTimerEx("LoginScreen2",15,1,"i",playerid);
		SetPlayerColor(playerid, COLOR_GREY);
	}
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    InventoryOnDialogResponse(playerid, dialogid, response, inputtext);
	switch(dialogid)
	{
		case DIALOG_REGISTER:
		{

			if(strlen(inputtext) < 3 || strlen(inputtext) > 20)
			{
				SendClientMessage(playerid, COLOR_RED, "{FF0000}ERROR: {FFFFFF}Your password must stay between 3 and 20 characters!");
				tmp = "Account: {F4C60F}";
				strcat(tmp, PlayerName);
				strcat(tmp, " {FFFFFF}(register)");
				ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, tmp, "You are about to register your account for Andreas-RP.\nPlease type in your desired password.\nMake sure you remember it!", "Register", "");
				return true;
			}

			GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
			mysql_real_escape_string(inputtext, str);
			GetPlayerIp(playerid, tmp, sizeof(tmp));

			format(query, sizeof(query), "INSERT INTO accounts (name, pass, ip) VALUES ('%s', SHA1('%s'), '%s')", PlayerName, str, tmp);
			mysql_query(query);
			PlayerInfo[playerid][pSQLID] = mysql_insert_id();

			SendClientMessage(playerid, COLOR_YELLOW, "Account registered, you can login now.");

			// Log player in, show characters menu
			pLogged{playerid} = true;
			ShowCharactersMenu(playerid);
		}
		case DIALOG_LOGIN:
		{
			GetPlayerName(playerid, PlayerName, sizeof(PlayerName));

			if(strlen(inputtext) < 3 || strlen(inputtext) > 20)
			{
				SendClientMessage(playerid, COLOR_RED, "{FF0000}ERROR: {FFFFFF}The password you entered is invalid");
				tmp = "Account: {F4C60F}";
				strcat(tmp, PlayerName);
				strcat(tmp, " {FFFFFF}(log in)");
				ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, tmp, "If this is your account, please enter your password to log in.", "Login", "");
				return true;
			}
			mysql_real_escape_string(inputtext, str);
			format(query, sizeof(query), "SELECT * FROM accounts WHERE name = '%s' AND pass = SHA1('%s') LIMIT 0,1", PlayerName, str);
			mysql_query(query);
			mysql_store_result();
			if(mysql_num_rows())
			{
				// Password valid
				SendClientMessage(playerid, 0x00FF9DFF, "{E80FCC}SERVER: {FFFFFF}You have succesfully logged in.");
				mysql_fetch_row_format(line);
				sscanf(line, "p<|>i{s[24]s[24]s[24]ii}", PlayerInfo[playerid][pSQLID]);
				mysql_free_result();
				ShowCharactersMenu(playerid);
				return true;
			}

			// nope!
			SendClientMessage(playerid, COLOR_RED, "{FF0000}ERROR: {FFFFFF}The password you entered is invalid");
			tmp = "Account: {F4C60F}";
			strcat(tmp, PlayerName);
			strcat(tmp, " {FFFFFF}(log in)");
			ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, tmp, "If this is your account, please enter your password to log in.", "Login", "");
            mysql_free_result();
		}
	    case DIALOG_CHAR:
	    {
			if(response)
			{
				// Picked "options," means the current char list is a no-go
				if(GetPVarType(playerid, "DELETING") == PLAYER_VARTYPE_INT) DeletePVar(playerid, "DELETING");
				ShowPlayerDialog(playerid, DIALOG_OPTIONS, DIALOG_STYLE_LIST, "Options menu - Options", "- Create a character\n- Delete character\n- Characters menu\n- Account settings", "Select", "Back");
				return true;
			}

			// Wants to spawn with a character
			if(!GetPVarInt(playerid, "CHAR_COUNT"))
			{
				SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid character (uncounted for), unable to spawn.");
				ShowCharactersMenu(playerid);
				return 1;
			}

			if(GetPVarType(playerid, "DELETING") == PLAYER_VARTYPE_INT)
			{
				DeletePVar(playerid, "DELETING");

				format(str, sizeof(str), "{FF0000}WARNING: {FFFFFF}You have deleted %s.", inputtext);
				SendClientMessage(playerid, COLOR_RED, str);

				format(query, sizeof(query), "DELETE FROM characters WHERE name = '%s' LIMIT 1", inputtext);
        		mysql_query(query);

				ShowCharactersMenu(playerid);
				return true;
			}

			format(query, sizeof(query), "SELECT id,name,x,y,z,a,interior,model,money,health,armor,age, faction, Rank, Paycheck, Pay FROM characters WHERE name = '%s' LIMIT 0,1", inputtext);
			mysql_query(query);
			mysql_store_result();
			// Is it a valid entry?
			if(!mysql_num_rows())
			{
				SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid character (not in the database), unable to spawn.");
				ShowCharactersMenu(playerid);
				mysql_free_result();
				return 1;
			}
			mysql_fetch_row_format(line);
			new Float:health, Float:armor;
			HideLogBox(playerid);
			TextDrawShowForPlayer(playerid, Clock);
			sscanf(line, "p<|>is[24]ffffiiiffiii", PlayerInfo[playerid][cSQLID], PlayerName, POS[0], POS[1], POS[2], POS[3], year, day, second, health, armor, minute, PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pRank], PlayerInfo[playerid][pPaycheck], PlayerInfo[playerid][pPay]);
			mysql_free_result();
			SetPVarInt(playerid, "CALLING_TO", -1);
			TogglePlayerSpectating(playerid, false);
			SetPlayerHealth(playerid, health);
			SetPlayerArmour(playerid, armor);
			SetSpawnInfo( playerid, playerid, day, POS[0], POS[1], POS[2], POS[3], 0, 0, 0, 0, 0, 0 );
			SpawnPlayer(playerid);
			SetPVarInt(playerid, "Building", -1);
			SetPVarInt(playerid, "Offerer", -1);
			SetPlayerInterior(playerid, year);
			KillTimer(logscr[playerid]);
			SetCameraBehindPlayer(playerid);
			GivePlayerMoney(playerid, second);
			format(str, sizeof(str), "%s (id:%i)", PlayerName, playerid);
            NickLabel[playerid] = Create3DTextLabel(str,COLOR_WHITE,30.0,40.0,50.0,20.0, -1,1);
    		Attach3DTextLabelToPlayer(NickLabel[playerid], playerid, 0.0, 0.0, 0.2);
    		SetPVarInt(playerid, "SPAWNED", 1);
    		SetPlayerColor(playerid, COLOR_WHITE);
    		LoadInventory(playerid);
		}
		case DIALOG_OPTIONS:
		{
			if(!response) return ShowCharactersMenu(playerid), true;

			switch(listitem)
			{
				case 0:
				{
					if(GetPVarInt(playerid, "CHAR_COUNT") == 5)
					{
						SendClientMessage(playerid, COLOR_RED, "{FF0000}WARNING: {FFFFFF}You can't have more than 5 characters!");
						ShowCharactersMenu(playerid);
						return true;
					}
					dialog_CreateChar(playerid);
				}
				case 1:
				{
					SetPVarInt(playerid, "DELETING", 1);
					SendClientMessage(playerid, COLOR_LIGHTRED, "Select the character you want to delete (this action cannot be undone!)");
					ShowCharactersMenu(playerid);
					return true;
				}
				case 2:
				{
					ShowCharactersMenu(playerid);
					return true;
				}
				case 3:
				{
					ShowSettingsMenu(playerid);
                    return true;
				}
			}
		}
		case DIALOG_SETTINGS:
		{
			if(!response)
			{
				ShowPlayerDialog(playerid, DIALOG_OPTIONS, DIALOG_STYLE_LIST, "Options menu - Options", "- Create a character\n- Delete character\n- Characters menu\n- Account settings", "Select", "Back");
     			return true;
			}

			switch(listitem)
			{
				case 0:
				{
					if(!GetPVarInt(playerid, "AUTO_LOG"))
					{
					   SetPVarInt(playerid, "AUTO_LOG", 1);
					   format(query, sizeof(query), "UPDATE Accounts SET AutoLogin=1 WHERE id =%i", PlayerInfo[playerid][pSQLID]);
   					   mysql_query(query);
   					   SendClientMessage(playerid, COLOR_YELLOW, "{FFFD96}INFO:{FFFFFF} Auto login has been {FFFD96}ENABLED.");
					}
					else
					{
					   DeletePVar(playerid, "AUTO_LOG");
					   format(query, sizeof(query), "UPDATE Accounts SET AutoLogin=0 WHERE id =%i", PlayerInfo[playerid][pSQLID]);
   					   mysql_query(query);
   					   SendClientMessage(playerid, COLOR_YELLOW, "{FFFD96}INFO:{FFFFFF} Auto login has been {FF0000}DISABLED.");
    			    }
    			    ShowSettingsMenu(playerid);
					return true;
				}
			}
		}
		case DIALOG_CREATE_CHAR:
		{
			if(!response)
			{
				ShowPlayerDialog(playerid, DIALOG_OPTIONS, DIALOG_STYLE_LIST, "Options menu - Options", "- Create a character\n- Delete character\n- Characters menu\n- Account settings", "Select", "Back");
     			return true;
			}


			// Do we have proper name length?
			if(strlen(inputtext) < 6 || strlen(inputtext) > 24)
			{
				SendClientMessage(playerid, COLOR_RED, "{FF0000}ERROR: {FFFFFF}Character name must stay between 6 and 24 characters!");
				dialog_CreateChar(playerid);
				return true;
			}

			new spaces;
            for(new n = 0; n < strlen(inputtext); n++)
            {
       		        if (inputtext[n] == ']' || inputtext[n] == '[' ||  inputtext[n] == '_' ||  inputtext[n] == '>' ||  inputtext[n] == '<' ||  inputtext[n] == '-' )
					{
                       SendClientMessage(playerid, COLOR_RED, "{FF0000}ERROR: {FFFFFF}Character name can only contain chracters A-Z, a-z and a space!");
  			           dialog_CreateChar(playerid);
					   return 1;
					}
					if(inputtext[n] == '1' || inputtext[n] == '2' || inputtext[n] == '3' || inputtext[n] == '4' || inputtext[n] == '5' || inputtext[n] == '6' || inputtext[n] == '7' || inputtext[n] == '8' || inputtext[n] == '9' || inputtext[n] == '0')
					{
					   SendClientMessage(playerid, COLOR_RED, "{FF0000}ERROR: {FFFFFF}Character name can only contain chracters A-Z, a-z and a space!");
				       dialog_CreateChar(playerid);
					   return 1;
					}
					if(inputtext[n] == ' ')
					{
					   spaces ++;
					}
			}
			if(spaces != 1)
			{
				SendClientMessage(playerid, COLOR_RED, "{FF0000}ERROR: {FFFFFF}Character names must contain only one space!");
				dialog_CreateChar(playerid);
				return true;
			}

			// Does the character name already exist?
			mysql_real_escape_string(inputtext, tmp);
			format(query, sizeof(query), "SELECT NULL FROM characters WHERE name = '%s' LIMIT 0,1", tmp);
			mysql_query(query);
			mysql_store_result();
			if(mysql_num_rows())
			{
				// Character with this name already exists!
				format(str, sizeof(str), "{FFFD96}INFO:{FFFFFF} We're sorry, the name {49F69D}%s {FFFFFF}already exists in our world.", inputtext);
				SendClientMessage(playerid, 0x0DCC1DFF, str);
				dialog_CreateChar(playerid);
				mysql_free_result();
				return true;
			}
			mysql_free_result();

			// Insert the character :>
			format(query, sizeof(query), "INSERT INTO characters (pid, name) VALUES (%i, '%s')", PlayerInfo[playerid][pSQLID], tmp);
			mysql_query(query);
			PlayerInfo[playerid][cSQLID] = mysql_insert_id();
			
			format(str, sizeof(str), "{FFFD96}INFO:{FFFFFF} Congratulations, you have created character {49F69D}%s{FFFFFF}.", tmp);
			SendClientMessage(playerid, 0x0DCC1DFF, str);
			SetPVarString(playerid, "CREATE_CHAR", inputtext);
			ShowCharactersMenu(playerid);
		}
		case DIALOG_VEHICLE_RENT:
		{
			if(!response) return RemovePlayerFromVehicle(playerid);
			new VehID = GetPlayerVehicleID(playerid);
			if(GetPlayerMoney(playerid) < VehicleInfo[VehID][vrent]) return SendClientMessage(playerid, COLOR_RED, "{FF0000}ERROR: {FFFFFF}You can't afford renting this vehicle!"), RemovePlayerFromVehicle(playerid);
			PlayerInfo[playerid][cRented] = VehID;
			GivePlayerMoney(playerid, -VehicleInfo[VehID][vrent]);
			VehicleInfo[VehID][vRented] = PlayerInfo[playerid][cSQLID];
            new VehicleName[24];
            GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
			new m_str[128];
			format(m_str, 128, "You have rented {FF0000}%s{FFFFFF} for {00F52D}%s{FFFFFF}. View {FF0000}/help{FFFFFF} for available commands.", VehicleName, FormatMoney(VehicleInfo[VehID][vrent]));
			SendClientMessage(playerid, COLOR_WHITE, m_str);
			return true;
		}
        case DIALOG_CREATE_HOUSE:
		   {
		        if(response == 1)
				{
		            sell = strval(inputtext);
		            ShowPlayerDialog(playerid, DIALOG_HOUSE_LEVEL, DIALOG_STYLE_INPUT, "Create house", "Enter house level! 0-12", "Submit", "Cancel");
		        }
		        return true;
	    }
        case DIALOG_HOUSE_LEVEL:
		{
		        if(response == 1)
				{
		            level = strval(inputtext);
		            CreatePlayerHouse(playerid, sell, level);
		        }
		        return true;
        }
        case DIALOG_HOUSE_CONFIRM:
        {
			   if(response == 1)
			   {
        			foreach(House, h)
					{
            			if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ]))
						{
                			HouseInfo[h][hSellable] = 0;
							GivePlayerMoney(playerid, -HouseInfo[h][hSell]);
                			HouseInfo[h][hSQLIDowner] = PlayerInfo[playerid][cSQLID];
							SavePlayerHouse(h);
							return 1;
						}
					}
			   }
        }
        case DIALOG_BUSINESS_CONFIRM:
        {
			   if(response == 1)
			   {
        			foreach(Businesses, b)
					{
            			if(IsPlayerInRangeOfPoint(playerid, 2, BusinessInfo[b][bcoords][0], BusinessInfo[b][bcoords][1], BusinessInfo[b][bcoords][2]))
						{
                			BusinessInfo[b][bowner] = PlayerInfo[playerid][cSQLID];
							GivePlayerMoney(playerid, -BusinessInfo[b][bprice]);
							SaveBusiness(b);
							return 1;
						}
					}
			   }
        }
        case DIALOG_WEAPON_SHOP:
        {
			   if(response == 0) return true;
			   new id = GetPVarInt(playerid, "BUSINESS");
			   switch(listitem)
			   {
					case 0:
					{
						   if(GetPlayerMoney(playerid) < 600)
						   {
						       ShowInfo(playerid, "You can't afford this item.");
	  						   ShowPlayerDialog(playerid, DIALOG_WEAPON_SHOP, DIALOG_STYLE_LIST, "{B500FC}Weapons shop",  "9mm (120 ammo)\t\t\t{FFBF00}$600.00\n{FFFFFF}Shotgun (60 ammo)\t\t\t{FFBF00}$700.00\n{FFFFFF}Hunting rifle (40 ammo)\t\t\t{FFBF00}$300.00\n{FFFFFF}Armour\t\t\t\t\t{FFBF00}$100.00", "Buy", "Exit");
							   return true;
						   }
						   BusinessInfo[id][bbank] += 600;
						   GivePlayerMoney(playerid, - 600);
						   AddItem(playerid, "9mm", 1);
						   ShowPlayerDialog(playerid, DIALOG_WEAPON_SHOP, DIALOG_STYLE_LIST, "{B500FC}Weapons shop",  "9mm (120 ammo)\t\t\t{FFBF00}$600.00\n{FFFFFF}Shotgun (60 ammo)\t\t\t{FFBF00}$700.00\n{FFFFFF}Hunting rifle (40 ammo)\t\t\t{FFBF00}$300.00\n{FFFFFF}Armour\t\t\t\t\t{FFBF00}$100.00", "Buy", "Exit");
						   SaveBusiness(id);
						   return true;
					}
					case 1:
					{
						   if(GetPlayerMoney(playerid) < 700)
						   {
						       ShowInfo(playerid, "You can't afford this item.");
  							   ShowPlayerDialog(playerid, DIALOG_WEAPON_SHOP, DIALOG_STYLE_LIST, "{B500FC}Weapons shop",  "9mm (120 ammo)\t\t\t{FFBF00}$600.00\n{FFFFFF}Shotgun (60 ammo)\t\t\t{FFBF00}$700.00\n{FFFFFF}Hunting rifle (40 ammo)\t\t\t{FFBF00}$300.00\n{FFFFFF}Armour\t\t\t\t\t{FFBF00}$100.00", "Buy", "Exit");
							   return true;
						   }
						   BusinessInfo[id][bbank] += 700;
						   GivePlayerMoney(playerid, - 700);
						   AddItem(playerid, "Shotgun", 1);
					       ShowPlayerDialog(playerid, DIALOG_WEAPON_SHOP, DIALOG_STYLE_LIST, "{B500FC}Weapons shop",  "9mm (120 ammo)\t\t\t{FFBF00}$600.00\n{FFFFFF}Shotgun (60 ammo)\t\t\t{FFBF00}$700.00\n{FFFFFF}Hunting rifle (40 ammo)\t\t\t{FFBF00}$300.00\n{FFFFFF}Armour\t\t\t\t\t{FFBF00}$100.00", "Buy", "Exit");
                           SaveBusiness(id);
						   return true;
					}
					case 2:
					{
						   if(GetPlayerMoney(playerid) < 300)
						   {
						       ShowInfo(playerid, "You can't afford this item.");
  							   ShowPlayerDialog(playerid, DIALOG_WEAPON_SHOP, DIALOG_STYLE_LIST, "{B500FC}Weapons shop",  "9mm (120 ammo)\t\t\t{FFBF00}$600.00\n{FFFFFF}Shotgun (60 ammo)\t\t\t{FFBF00}$700.00\n{FFFFFF}Hunting rifle (40 ammo)\t\t\t{FFBF00}$300.00\n{FFFFFF}Armour\t\t\t\t\t{FFBF00}$100.00", "Buy", "Exit");
							   return true;
						   }
						   BusinessInfo[id][bbank] += 300;
						   GivePlayerMoney(playerid, - 300);
						   AddItem(playerid, "Hunting Rifle", 1);
					       ShowPlayerDialog(playerid, DIALOG_WEAPON_SHOP, DIALOG_STYLE_LIST, "{B500FC}Weapons shop",  "9mm (120 ammo)\t\t\t{FFBF00}$600.00\n{FFFFFF}Shotgun (60 ammo)\t\t\t{FFBF00}$700.00\n{FFFFFF}Hunting rifle (40 ammo)\t\t\t{FFBF00}$300.00\n{FFFFFF}Armour\t\t\t\t\t{FFBF00}$100.00", "Buy", "Exit");
                           SaveBusiness(id);
						   return true;
					}
					case 3:
					{
						   if(GetPlayerMoney(playerid) < 100)
						   {
						       ShowInfo(playerid, "You can't afford this item.");
  							   ShowPlayerDialog(playerid, DIALOG_WEAPON_SHOP, DIALOG_STYLE_LIST, "{B500FC}Weapons shop",  "9mm (120 ammo)\t\t\t{FFBF00}$600.00\n{FFFFFF}Shotgun (60 ammo)\t\t\t{FFBF00}$700.00\n{FFFFFF}Hunting rifle (40 ammo)\t\t\t{FFBF00}$300.00\n{FFFFFF}Armour\t\t\t\t\t{FFBF00}$100.00", "Buy", "Exit");
							   return true;
						   }
						   BusinessInfo[id][bbank] += 100;
						   GivePlayerMoney(playerid, - 100);
						   AddItem(playerid, "Body Armour", 1);
					       ShowPlayerDialog(playerid, DIALOG_WEAPON_SHOP, DIALOG_STYLE_LIST, "{B500FC}Weapons shop",  "9mm (120 ammo)\t\t\t{FFBF00}$600.00\n{FFFFFF}Shotgun (60 ammo)\t\t\t{FFBF00}$700.00\n{FFFFFF}Hunting rifle (40 ammo)\t\t\t{FFBF00}$300.00\n{FFFFFF}Armour\t\t\t\t\t{FFBF00}$100.00", "Buy", "Exit");
                           SaveBusiness(id);
						   return true;
					}
			   }
		}
		case DIALOG_CLUB_SHOP:
		{
			   if(response == 0) return true;
			   new id = GetPVarInt(playerid, "BUSINESS");
			   switch(listitem)
			   {
					case 0:
					{
						   if(GetPlayerMoney(playerid) < 4)
						   {
						       ShowInfo(playerid, "You can't afford this item.");
	  						   ShowPlayerDialog(playerid, DIALOG_CLUB_SHOP, DIALOG_STYLE_LIST, "{B500FC}Drinks",  "Beer\t\t\t{FFBF00}$4.00\n{FFFFFF}Wine\t\t\t{FFBF00}$6.00\n{FFFFFF}Vodka\t\t\t{FFBF00}$5.00\n{FFFFFF}Sprunk\t\t\t{FFBF00}$1.00", "Buy", "Exit");
							   return true;
						   }
						   BusinessInfo[id][bbank] += 4;
						   GivePlayerMoney(playerid, - 4);
						   AddItem(playerid, "Beer", 1);
						   ShowPlayerDialog(playerid, DIALOG_CLUB_SHOP, DIALOG_STYLE_LIST, "{B500FC}Drinks",  "Beer\t\t\t{FFBF00}$4.00\n{FFFFFF}Wine\t\t\t{FFBF00}$6.00\n{FFFFFF}Vodka\t\t\t{FFBF00}$5.00\n{FFFFFF}Sprunk\t\t\t{FFBF00}$1.00", "Buy", "Exit");
                           SaveBusiness(id);
						   return true;
					}
					case 1:
					{
						   if(GetPlayerMoney(playerid) < 6)
						   {
						       ShowInfo(playerid, "You can't afford this item.");
	  						   ShowPlayerDialog(playerid, DIALOG_CLUB_SHOP, DIALOG_STYLE_LIST, "{B500FC}Drinks",  "Beer\t\t\t{FFBF00}$4.00\n{FFFFFF}Wine\t\t\t{FFBF00}$6.00\n{FFFFFF}Vodka\t\t\t{FFBF00}$5.00\n{FFFFFF}Sprunk\t\t\t{FFBF00}$1.00", "Buy", "Exit");
							   return true;
						   }
						   BusinessInfo[id][bbank] += 6;
						   GivePlayerMoney(playerid, - 6);
						   AddItem(playerid, "Wine", 1);
						   ShowPlayerDialog(playerid, DIALOG_CLUB_SHOP, DIALOG_STYLE_LIST, "{B500FC}Drinks",  "Beer\t\t\t{FFBF00}$4.00\n{FFFFFF}Wine\t\t\t{FFBF00}$6.00\n{FFFFFF}Vodka\t\t\t{FFBF00}$5.00\n{FFFFFF}Sprunk\t\t\t{FFBF00}$1.00", "Buy", "Exit");
                           SaveBusiness(id);
						   return true;
					}
					case 2:
					{
						   if(GetPlayerMoney(playerid) < 5)
						   {
						       ShowInfo(playerid, "You can't afford this item.");
	  						   ShowPlayerDialog(playerid, DIALOG_CLUB_SHOP, DIALOG_STYLE_LIST, "{B500FC}Drinks",  "Beer\t\t\t{FFBF00}$4.00\n{FFFFFF}Wine\t\t\t{FFBF00}$6.00\n{FFFFFF}Vodka\t\t\t{FFBF00}$5.00\n{FFFFFF}Sprunk\t\t\t{FFBF00}$1.00", "Buy", "Exit");
							   return true;
						   }
						   BusinessInfo[id][bbank] += 5;
						   GivePlayerMoney(playerid, - 5);
						   AddItem(playerid, "Vodka", 1);
						   ShowPlayerDialog(playerid, DIALOG_CLUB_SHOP, DIALOG_STYLE_LIST, "{B500FC}Drinks",  "Beer\t\t\t{FFBF00}$4.00\n{FFFFFF}Wine\t\t\t{FFBF00}$6.00\n{FFFFFF}Vodka\t\t\t{FFBF00}$5.00\n{FFFFFF}Sprunk\t\t\t{FFBF00}$1.00", "Buy", "Exit");
                           SaveBusiness(id);
						   return true;
					}
					case 3:
					{
						   if(GetPlayerMoney(playerid) < 1)
						   {
						       ShowInfo(playerid, "You can't afford this item.");
	  						   ShowPlayerDialog(playerid, DIALOG_CLUB_SHOP, DIALOG_STYLE_LIST, "{B500FC}Drinks",  "Beer\t\t\t{FFBF00}$4.00\n{FFFFFF}Wine\t\t\t{FFBF00}$6.00\n{FFFFFF}Vodka\t\t\t{FFBF00}$5.00\n{FFFFFF}Sprunk\t\t\t{FFBF00}$1.00", "Buy", "Exit");
							   return true;
						   }
						   BusinessInfo[id][bbank] += 1;
						   GivePlayerMoney(playerid, - 1);
						   AddItem(playerid, "Sprunk", 1);
						   ShowPlayerDialog(playerid, DIALOG_CLUB_SHOP, DIALOG_STYLE_LIST, "{B500FC}Drinks",  "Beer\t\t\t{FFBF00}$4.00\n{FFFFFF}Wine\t\t\t{FFBF00}$6.00\n{FFFFFF}Vodka\t\t\t{FFBF00}$5.00\n{FFFFFF}Sprunk\t\t\t{FFBF00}$1.00", "Buy", "Exit");
                           SaveBusiness(id);
						   return true;
					}
			   }
		}
		case DIALOG_ELECTRONIC_SHOP:
		{
             new id = GetPVarInt(playerid, "BUSINESS");
             if(response == 0) return 1;
			 switch(listitem)
			 {
				  case 0:
				  {
							   if(GetPlayerMoney(playerid) < 200)
							   {
							       ShowInfo(playerid, "You can't afford this item.");
		  						   ShowPlayerDialog(playerid, DIALOG_ELECTRONIC_SHOP, DIALOG_STYLE_LIST, "{B500FC}Electronics",  LIST_ELECTRONICS, "Buy", "Exit");
								   return true;
							   }
							   BusinessInfo[id][bbank] += 200;
							   GivePlayerMoney(playerid, - 200);
							   AddItem(playerid, "Laptop", 1);
							   ShowPlayerDialog(playerid, DIALOG_ELECTRONIC_SHOP, DIALOG_STYLE_LIST, "{B500FC}Electronics",  LIST_ELECTRONICS, "Buy", "Exit");
	                           SaveBusiness(id);
							   return true;
				  }
				  case 1:
				  {
							   if(GetPlayerMoney(playerid) < 15)
							   {
							       ShowInfo(playerid, "You can't afford this item.");
		  						   ShowPlayerDialog(playerid, DIALOG_ELECTRONIC_SHOP, DIALOG_STYLE_LIST, "{B500FC}Electronics",  LIST_ELECTRONICS, "Buy", "Exit");
								   return true;
							   }
							   BusinessInfo[id][bbank] += 15;
							   GivePlayerMoney(playerid, - 15);
							   AddItem(playerid, "Walkie Talkie", 1);
							   ShowPlayerDialog(playerid, DIALOG_ELECTRONIC_SHOP, DIALOG_STYLE_LIST, "{B500FC}Electronics",  LIST_ELECTRONICS, "Buy", "Exit");
	                           SaveBusiness(id);
							   return true;
				  }
				  case 2:
				  {
							   if(GetPlayerMoney(playerid) < 80)
							   {
							       ShowInfo(playerid, "You can't afford this item.");
		  						   ShowPlayerDialog(playerid, DIALOG_ELECTRONIC_SHOP, DIALOG_STYLE_LIST, "{B500FC}Electronics",  LIST_ELECTRONICS, "Buy", "Exit");
								   return true;
							   }
							   BusinessInfo[id][bbank] += 80;
							   GivePlayerMoney(playerid, - 80);
							   AddItem(playerid, "Cellphone", 1);
							   PlayerInfo[playerid][pNumber] = random(9999) + 1000 + PlayerInfo[playerid][cSQLID];
							   ShowPlayerDialog(playerid, DIALOG_ELECTRONIC_SHOP, DIALOG_STYLE_LIST, "{B500FC}Electronics",  LIST_ELECTRONICS, "Buy", "Exit");
	                           SaveBusiness(id);
							   return true;
				  }
				  case 3:
				  {
							   if(GetPlayerMoney(playerid) < 50)
							   {
							       ShowInfo(playerid, "You can't afford this item.");
		  						   ShowPlayerDialog(playerid, DIALOG_ELECTRONIC_SHOP, DIALOG_STYLE_LIST, "{B500FC}Electronics",  LIST_ELECTRONICS, "Buy", "Exit");
								   return true;
							   }
							   BusinessInfo[id][bbank] += 50;
							   GivePlayerMoney(playerid, - 50);
							   AddItem(playerid, "GPS", 1);
							   ShowPlayerDialog(playerid, DIALOG_ELECTRONIC_SHOP, DIALOG_STYLE_LIST, "{B500FC}Electronics",  LIST_ELECTRONICS, "Buy", "Exit");
	                           SaveBusiness(id);
							   return true;
				  }
			 }
	    }
		case DIALOG_SHOP_STYLE:
		{
			   if(response == 0) return true;
			   new id = GetPVarInt(playerid, "BUSINESS");
			   switch(listitem)
			   {
					case 0:
					{
						   if(GetPlayerMoney(playerid) < 70)
						   {
						       ShowInfo(playerid, "You can't afford this item.");
	  						   ShowPlayerDialog(playerid, DIALOG_SHOP_STYLE, DIALOG_STYLE_LIST, "{B500FC}Fighting styles",  "Boxing\t\t\t{FFBF00}$70.00\n{FFFFFF}Kungfu\t\t\t{FFBF00}$100.00\n{FFFFFF}Grabkick\t\t\t{FFBF00}$80.00\n{FFFFFF}Elbow\t\t\t{FFBF00}$40.00", "Train", "Exit");
							   return true;
						   }
						   format(query, sizeof(query), "SELECT cid FROM fightstyles WHERE id =%i AND cid = 5", PlayerInfo[playerid][cSQLID]);
					       mysql_query(query);
					       mysql_store_result();
					       if(mysql_num_rows() == 1)
					       {
					           ShowInfo(playerid, "You already know this fighting style.");
	  						   ShowPlayerDialog(playerid, DIALOG_SHOP_STYLE, DIALOG_STYLE_LIST, "{B500FC}Fighting styles",  "Boxing\t\t\t{FFBF00}$70.00\n{FFFFFF}Kungfu\t\t\t{FFBF00}$100.00\n{FFFFFF}Grabkick\t\t\t{FFBF00}$80.00\n{FFFFFF}Elbow\t\t\t{FFBF00}$40.00", "Train", "Exit");
                               mysql_free_result();
							   return true;
						   }
						   mysql_free_result();
						   BusinessInfo[id][bbank] += 70;
						   GivePlayerMoney(playerid, - 70);
						   SetPlayerFightingStyle(playerid, FIGHT_STYLE_BOXING);
						   ShowInfo(playerid, "Your fighting style has been changed.");
						   SendClientMessage(playerid, COLOR_YELLOW, "HINT: You can change fighting styles anytime - /fightingstyle");
						   ShowPlayerDialog(playerid, DIALOG_SHOP_STYLE, DIALOG_STYLE_LIST, "{B500FC}Fighting styles",  "Boxing\t\t\t{FFBF00}$70.00\n{FFFFFF}Kungfu\t\t\t{FFBF00}$100.00\n{FFFFFF}Grabkick\t\t\t{FFBF00}$80.00\n{FFFFFF}Elbow\t\t\t{FFBF00}$40.00", "Train", "Exit");
                           format(query, sizeof(query), "INSERT INTO fightstyles (id, cid) VALUES ('%i', 5)", PlayerInfo[playerid][cSQLID]);
					       mysql_query(query);
                           SaveBusiness(id);
						   return true;
					}
					case 1:
					{
						   if(GetPlayerMoney(playerid) < 100)
						   {
						       ShowInfo(playerid, "You can't afford this item.");
	  						   ShowPlayerDialog(playerid, DIALOG_SHOP_STYLE, DIALOG_STYLE_LIST, "{B500FC}Fighting styles",  "Boxing\t\t\t{FFBF00}$70.00\n{FFFFFF}Kungfu\t\t\t{FFBF00}$100.00\n{FFFFFF}Grabkick\t\t\t{FFBF00}$80.00\n{FFFFFF}Elbow\t\t\t{FFBF00}$40.00", "Train", "Exit");
							   return true;
						   }
						   format(query, sizeof(query), "SELECT cid FROM fightstyles WHERE id =%i AND cid = 6", PlayerInfo[playerid][cSQLID]);
					       mysql_query(query);
					       mysql_store_result();
					       if(mysql_num_rows() == 1)
					       {
					           ShowInfo(playerid, "You already know this fighting style.");
	  						   ShowPlayerDialog(playerid, DIALOG_SHOP_STYLE, DIALOG_STYLE_LIST, "{B500FC}Fighting styles",  "Boxing\t\t\t{FFBF00}$70.00\n{FFFFFF}Kungfu\t\t\t{FFBF00}$100.00\n{FFFFFF}Grabkick\t\t\t{FFBF00}$80.00\n{FFFFFF}Elbow\t\t\t{FFBF00}$40.00", "Train", "Exit");
                               mysql_free_result();
							   return true;
						   }
						   mysql_free_result();
						   BusinessInfo[id][bbank] += 100;
						   GivePlayerMoney(playerid, - 100);
						   SetPlayerFightingStyle(playerid, FIGHT_STYLE_KUNGFU);
						   ShowInfo(playerid, "Your fighting style has been changed.");
						   SendClientMessage(playerid, COLOR_YELLOW, "HINT: You can change fighting styles anytime - /fightingstyle");
						   ShowPlayerDialog(playerid, DIALOG_SHOP_STYLE, DIALOG_STYLE_LIST, "{B500FC}Fighting styles",  "Boxing\t\t\t{FFBF00}$70.00\n{FFFFFF}Kungfu\t\t\t{FFBF00}$100.00\n{FFFFFF}Grabkick\t\t\t{FFBF00}$80.00\n{FFFFFF}Elbow\t\t\t{FFBF00}$40.00", "Train", "Exit");
                           format(query, sizeof(query), "INSERT INTO fightstyles (id, cid) VALUES ('%i', 6)", PlayerInfo[playerid][cSQLID]);
					       mysql_query(query);
                           SaveBusiness(id);
						   return true;
					}
					case 2:
					{
						   if(GetPlayerMoney(playerid) < 80)
						   {
						       ShowInfo(playerid, "You can't afford this item.");
	  						   ShowPlayerDialog(playerid, DIALOG_SHOP_STYLE, DIALOG_STYLE_LIST, "{B500FC}Fighting styles",  "Boxing\t\t\t{FFBF00}$70.00\n{FFFFFF}Kungfu\t\t\t{FFBF00}$100.00\n{FFFFFF}Grabkick\t\t\t{FFBF00}$80.00\n{FFFFFF}Elbow\t\t\t{FFBF00}$40.00", "Train", "Exit");
							   return true;
						   }
						   format(query, sizeof(query), "SELECT cid FROM fightstyles WHERE id =%i AND cid = 15", PlayerInfo[playerid][cSQLID]);
					       mysql_query(query);
					       mysql_store_result();
					       if(mysql_num_rows() == 1)
					       {
					           ShowInfo(playerid, "You already know this fighting style.");
	  						   ShowPlayerDialog(playerid, DIALOG_SHOP_STYLE, DIALOG_STYLE_LIST, "{B500FC}Fighting styles",  "Boxing\t\t\t{FFBF00}$70.00\n{FFFFFF}Kungfu\t\t\t{FFBF00}$100.00\n{FFFFFF}Grabkick\t\t\t{FFBF00}$80.00\n{FFFFFF}Elbow\t\t\t{FFBF00}$40.00", "Train", "Exit");
                               mysql_free_result();
							   return true;
						   }
						   mysql_free_result();
						   BusinessInfo[id][bbank] += 80;
						   GivePlayerMoney(playerid, - 80);
						   SetPlayerFightingStyle(playerid, FIGHT_STYLE_GRABKICK);
						   ShowInfo(playerid, "Your fighting style has been changed.");
						   SendClientMessage(playerid, COLOR_YELLOW, "HINT: You can change fighting styles anytime - /fightingstyle");
						   ShowPlayerDialog(playerid, DIALOG_SHOP_STYLE, DIALOG_STYLE_LIST, "{B500FC}Fighting styles",  "Boxing\t\t\t{FFBF00}$70.00\n{FFFFFF}Kungfu\t\t\t{FFBF00}$100.00\n{FFFFFF}Grabkick\t\t\t{FFBF00}$80.00\n{FFFFFF}Elbow\t\t\t{FFBF00}$40.00", "Train", "Exit");
                           format(query, sizeof(query), "INSERT INTO fightstyles (id, cid) VALUES ('%i', 15)", PlayerInfo[playerid][cSQLID]);
					       mysql_query(query);
                           SaveBusiness(id);
						   return true;
					}
					case 3:
					{
						   if(GetPlayerMoney(playerid) < 40)
						   {
						       ShowInfo(playerid, "You can't afford this item.");
	  						   ShowPlayerDialog(playerid, DIALOG_SHOP_STYLE, DIALOG_STYLE_LIST, "{B500FC}Fighting styles",  "Boxing\t\t\t{FFBF00}$70.00\n{FFFFFF}Kungfu\t\t\t{FFBF00}$100.00\n{FFFFFF}Grabkick\t\t\t{FFBF00}$80.00\n{FFFFFF}Elbow\t\t\t{FFBF00}$40.00", "Train", "Exit");
							   return true;
						   }
						   format(query, sizeof(query), "SELECT cid FROM fightstyles WHERE id =%i AND cid = 26", PlayerInfo[playerid][cSQLID]);
					       mysql_query(query);
					       mysql_store_result();
					       if(mysql_num_rows() == 1)
					       {
					           ShowInfo(playerid, "You already know this fighting style.");
	  						   ShowPlayerDialog(playerid, DIALOG_SHOP_STYLE, DIALOG_STYLE_LIST, "{B500FC}Fighting styles",  "Boxing\t\t\t{FFBF00}$70.00\n{FFFFFF}Kungfu\t\t\t{FFBF00}$100.00\n{FFFFFF}Grabkick\t\t\t{FFBF00}$80.00\n{FFFFFF}Elbow\t\t\t{FFBF00}$40.00", "Train", "Exit");
                               mysql_free_result();
							   return true;
						   }
						   mysql_free_result();
						   BusinessInfo[id][bbank] += 40;
						   GivePlayerMoney(playerid, - 40);
						   SetPlayerFightingStyle(playerid, FIGHT_STYLE_ELBOW);
						   ShowInfo(playerid, "Your fighting style has been changed.");
						   SendClientMessage(playerid, COLOR_YELLOW, "HINT: You can change fighting styles anytime - /fightingstyle");
						   ShowPlayerDialog(playerid, DIALOG_SHOP_STYLE, DIALOG_STYLE_LIST, "{B500FC}Fighting styles",  "Boxing\t\t\t{FFBF00}$70.00\n{FFFFFF}Kungfu\t\t\t{FFBF00}$100.00\n{FFFFFF}Grabkick\t\t\t{FFBF00}$80.00\n{FFFFFF}Elbow\t\t\t{FFBF00}$40.00", "Train", "Exit");
                           format(query, sizeof(query), "INSERT INTO fightstyles (id, cid) VALUES ('%i', 26)", PlayerInfo[playerid][cSQLID]);
					       mysql_query(query);
                           SaveBusiness(id);
						   return true;
					}
			   }
		}
		case DIALOG_CONFIGURE_RADIO:
		{
			   if(response == 0) return ShowInventory(playerid);
			   if(!IsNumeric(inputtext))
			   {
                 new string[128];
				 format(string, 128, "{33CCFF}Current channel:{FFFFFF} %i\nType in channel you wish to set.\n{FF3366}ERROR:{FFFFFF}Invalid channel.", PlayerInfo[playerid][pRadio]);
				 ShowPlayerDialog(playerid, DIALOG_CONFIGURE_RADIO, DIALOG_STYLE_INPUT, "Walkie Talkie", string, "Configure", "Exit");
				 return true;
			   }
	           new string[128];
               format(string, 128, "{33CCFF}Channel has been set to:{FFFFFF} %i", strval(inputtext));
			   PlayerInfo[playerid][pRadio] = strval(inputtext);
			   ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_MSGBOX, "Walkie talkie", string, "Okay", "");
			   return true;
		}
		case DIALOG_FIGHTING_STYLES:
		{
			   if(response == 0) return true;
			   ShowInfo(playerid, "Fighting style has been ~y~changed.");
    		   if(!strcmp(inputtext,"Normal",true))
			   {
                   SetPlayerFightingStyle(playerid, FIGHT_STYLE_NORMAL);
                   return true;
			   }
    		   if(!strcmp(inputtext,"KungFu",true))
			   {
                   SetPlayerFightingStyle(playerid, FIGHT_STYLE_KUNGFU);
                   return true;
			   }
    		   if(!strcmp(inputtext,"Boxing",true))
			   {
                   SetPlayerFightingStyle(playerid, FIGHT_STYLE_BOXING);
                   return true;
			   }
    		   if(!strcmp(inputtext,"GrabKick",true))
			   {
                   SetPlayerFightingStyle(playerid, FIGHT_STYLE_GRABKICK);
                   return true;
			   }
    		   if(!strcmp(inputtext,"Elbow",true))
			   {
                   SetPlayerFightingStyle(playerid, FIGHT_STYLE_ELBOW);
                   return true;
			   }
		}
        case LAPTOP_DIALOG:
        {
            if(!response) return 1;
            switch(listitem)
			{
                case 0:
                {
                    if(EmailBusy == 1) { ShowPlayerDialog(playerid, LAPTOP_DIALOG, DIALOG_STYLE_LIST, "Laptop", "- Send E-Mail\n- Check E-Mail\n- Goto Adress\n- Create my website\n- Edit my website", "Okay", "Shut Down"); SendClientMessage(playerid, 0xFFFF0096, "[Error]: E-mail service is currently busy, please try again later!"); return 1; }
                    ShowPlayerDialog(playerid, DIALOG_SEND_EMAIL, DIALOG_STYLE_INPUT, "Internet Browser", "Enter the recipent name without _", "Okay", "Back");
                }
                case 1:
                {
					ShowEmails(playerid);
				}
                case 2:
                {
                    ShowPlayerDialog(playerid, DIALOG_GOTO_ADRESS, DIALOG_STYLE_INPUT, "Internet Browser", "Enter the website! \n.info\n.net\n.com", "Okay", "Back");
                }
                case 3:
                {
                    ShowPlayerDialog(playerid, DIALOG_CREATE_WEB, DIALOG_STYLE_INPUT, "Internet Browser", "Enter the domain! It can be\nwww.yourdomain.com\nwww.yourdomain.info\nwww.yourdomain.net", "Okay", "Back");
                }
                case 4:
                {
                    ShowPlayerDialog(playerid, DIALOG_WEB_EDIT, DIALOG_STYLE_INPUT, "Internet Browser", "Enter the website what would you like to edit!", "Okay", "Back");
                }
                case 5:
                {
					ShowWebsiteList(playerid);
				}
            }
        }
        case DIALOG_CREATE_WEB:
        {
            if(!response)  return ShowPlayerDialog(playerid, LAPTOP_DIALOG, DIALOG_STYLE_LIST, "Laptop", "- Send E-Mail\n- Check E-Mail\n- Goto Adress\n- Create my website\n- Edit my website\n- Poogle", "Select", "Shut Down");
            if(strfind(inputtext, ".net", true) != -1 || strfind(inputtext, ".com", true) != -1 || strfind(inputtext, ".info", true) != -1) {
                if(strfind(inputtext, "www.", true) != -1) {
                    if(strlen(inputtext) < 5) { ShowPlayerDialog(playerid, LAPTOP_DIALOG, DIALOG_STYLE_LIST, "Laptop", "- Send E-Mail\n- Check E-Mail\n- Goto Adress\n- Create my website\n- Edit my website\n- Poogle", "Select", "Shut Down"); SendClientMessage(playerid, 0xFFFF0096, "[ERROR]: It must be atleast 5 characters long!"); return 1; }
                    format(query, sizeof(query), "SELECT WebAdress FROM webpages WHERE WebAdress = '%s'", inputtext);
            		mysql_query(query);
            		mysql_store_result();
					if(mysql_num_rows() == 1)
					{
                            SendClientMessage(playerid, 0xFFFF0096, "{FF0000}ERROR: {FFFFFF} There's already a website with that name!"); mysql_free_result(); return 1;
                    }
                    format(query, sizeof(query), "INSERT INTO Webpages (WebAdress, OwnerName, Visits) VALUES('%s', '%i', '%i')",
                    inputtext, PlayerInfo[playerid][cSQLID], 0);
                    mysql_free_result();
					mysql_query(query);
					new string[128];
					format(string, sizeof(string), "Congratulations, {F2F205}%s{FFFFFF} has been succesfully created!", inputtext);
                    SendClientMessage(playerid, 0xFFFF0096, string);
                    return true;
                } else  SendClientMessage(playerid, 0xFFFF0096, "{FF0000}ERROR: {FFFFFF} There must be a www. ");
            } else  SendClientMessage(playerid, 0xFFFF0096, "{FF0000}ERROR: {FFFFFF} The domain must be .info .com .net");
        }
        case DIALOG_GOTO_ADRESS:
        {
            if(!response) return ShowPlayerDialog(playerid, LAPTOP_DIALOG, DIALOG_STYLE_LIST, "Laptop", "- Send E-Mail\n- Check E-Mail\n- Goto Adress\n- Create my website\n- Edit my website\n- Poogle", "Select", "Shut Down");
            if(strfind(inputtext, ".net", true) != -1 || strfind(inputtext, ".com", true) != -1 || strfind(inputtext, ".info", true) != -1 )
			{
                if(strfind(inputtext, "www.", true) != -1 )
				{
                    if(strlen(inputtext) < 5) return SendClientMessage(playerid, 0xFFFF0096, "[ERROR]: It must be atleast 5 characters long!");
                    format(query, sizeof(query), "SELECT WebAdress, OwnerName, Content FROM webpages WHERE WebAdress = '%s'", inputtext);
            		mysql_query(query, THREAD_SHOW_WEB, playerid);
            		return true;
            		
                } else SendClientMessage(playerid, 0xFFFF0096, "{FF0000}ERROR: {FFFFFF} The domain must be .info .com .net");
            } else SendClientMessage(playerid, 0xFFFF0096, "{FF0000}ERROR: {FFFFFF} There must be a www. ");
        }
        case DIALOG_WEB_EDIT:
        {
            if(!response) return ShowPlayerDialog(playerid, LAPTOP_DIALOG, DIALOG_STYLE_LIST, "Laptop", "- Send E-Mail\n- Check E-Mail\n- Goto Adress\n- Create my website\n- Edit my website\n- Poogle", "Select", "Shut Down");
            if(strfind(inputtext, ".net", true) != -1 || strfind(inputtext, ".com", true) != -1 || strfind(inputtext, ".info", true) != -1 ) {
                if(strfind(inputtext, "www.", true) != -1 )
				{
                    	if(strlen(inputtext) < 5) return SendClientMessage(playerid, 0xFFFF0096, "{FF0000}ERROR: {FFFFFF It must be atleast 5 characters long!");
						new owner;
					    format(query, sizeof(query), "SELECT `OwnerName`,   `SQLid` FROM webpages WHERE WebAdress = '%s'", inputtext);
					    mysql_query(query);
					    mysql_store_result();
					    mysql_fetch_row_format(line,"|");
	    				sscanf(line, "p<|>ii", owner, webID[playerid]);
					 	mysql_free_result();
					 	if(owner == PlayerInfo[playerid][cSQLID])
					 	{
                    		format(query, sizeof(query), "SELECT WebAdress, OwnerName, Content FROM webpages WHERE WebAdress = '%s'", inputtext);
            				mysql_query(query, THREAD_EDIT_WEB, playerid);
            				return true;
						}
                } else SendClientMessage(playerid, 0xFFFF0096, "{FF0000}ERROR: {FFFFFF} The domain must be .info .com .net");
            } else SendClientMessage(playerid, 0xFFFF0096, "{FF0000}ERROR: {FFFFFF} There must be a www. ");
        }
        case DIALOG_WEB_EDIT2:
        {
            if(!response) return ShowPlayerDialog(playerid, LAPTOP_DIALOG, DIALOG_STYLE_LIST, "Laptop", "- Send E-Mail\n- Check E-Mail\n- Goto Adress\n- Create my website\n- Edit my website\n- Poogle", "Select", "Shut Down");
            format(query, sizeof(query), "UPDATE webpages SET Content = '%s' WHERE SQLid =%i", inputtext, webID[playerid]);
	        mysql_query(query);
            webID[playerid] = -1;
			ShowPlayerDialog(playerid, LAPTOP_DIALOG, DIALOG_STYLE_LIST, "Laptop", "- Send E-Mail\n- Check E-Mail\n- Goto Adress\n- Create my website\n- Edit my website\n- Poogle", "Select", "Shut Down");
        }
        case DIALOG_SEND_EMAIL:
        {
            if(!response) return ShowPlayerDialog(playerid, LAPTOP_DIALOG, DIALOG_STYLE_LIST, "Laptop", "- Send E-Mail\n- Check E-Mail\n- Goto Adress\n- Create my website\n- Edit my website\n - Poogle", "Select", "Shut Down"),EmailBusy = 0;
            if(strlen(inputtext) < 5) return SendClientMessage(playerid, 0xFFFF0096, "{FF0000}ERROR: {FFFFFF} Too short!");
            EmailBusy = 1;
            format(query, sizeof(query), "SELECT * FROM characters WHERE name = '%s'", inputtext);
            mysql_query(query);
            mysql_store_result();
            if(mysql_num_rows() < 1) { SendClientMessage(playerid, 0xFFFF0096, "{FF0000}ERROR: {FFFFFF} The name isn't registered!"); EmailBusy = 0; mysql_free_result(); return 1; }
            format(query, sizeof(query), "SELECT * FROM email WHERE SendingTo = %i", GetUserDBID(inputtext));
            mysql_query(query);
            mysql_store_result();
            if(mysql_num_rows() > MAX_MAILS) { SendClientMessage(playerid, 0xFFFF0096, "{FF0000}ERROR: {FFFFFF} The user's e-mail is full!"); EmailBusy = 0; mysql_free_result(); return 1; }
            SendingTo = GetUserDBID(inputtext);
            ShowPlayerDialog(playerid, DIALOG_SEND_EMAIL_SUBJECT, DIALOG_STYLE_INPUT, "Internet Browser", "Enter the subject", "Okay", "Back");
            mysql_free_result();
        }
        case DIALOG_SEND_EMAIL_SUBJECT:
        {
            if(!response) return ShowPlayerDialog(playerid, LAPTOP_DIALOG, DIALOG_STYLE_LIST, "Laptop", "- Send E-Mail\n- Check E-Mail\n- Goto Adress\n- Create my website\n- Edit my website\n - Poogle", "Select", "Shut Down"),EmailBusy = 0;
            if(strlen(inputtext) < 5 || strlen(inputtext) > 60) { SendClientMessage(playerid, 0xFFFF0096, "{FF0000}ERROR: {FFFFFF} Too short(5 characters) or too big(60 characters)"); EmailBusy = 0; return 1; }
            format(EmailSubject, 64, "%s", inputtext);
            ShowPlayerDialog(playerid, DIALOG_SEND_EMAIL_BODY, DIALOG_STYLE_INPUT, "Internet Browser", "{FFFFFF}Enter the text what you want to be sent\n{FFBF00}You may view /help to see how you can send colored messages etc..", "Okay", "Back");
        }
        case DIALOG_SEND_EMAIL_BODY:
        {
            if(!response) return ShowPlayerDialog(playerid, LAPTOP_DIALOG, DIALOG_STYLE_LIST, "Laptop", "- Send E-Mail\n- Check E-Mail\n- Goto Adress\n- Create my website\n- Edit my website\n - Poogle", "Select", "Shut Down"),EmailBusy = 0;
            if(strlen(inputtext) < 8 || strlen(inputtext) > 120) { SendClientMessage(playerid, 0xFFFF0096, "{FF0000}ERROR: {FFFFFF} Too short(8 characters) or too big(120 characters)"); EmailBusy = 0; return 1; }
            new Year, Month, Day;
            new subb[60];
            getdate(Year, Month, Day);
            format(EmailBody, 128, "%s", inputtext);
            mysql_real_escape_string(EmailBody, str);
            mysql_real_escape_string(EmailSubject, subb);
            format(query, sizeof(query), "INSERT INTO email (Sender, SendingTo, EmailSubject, EmailBody, Year, Month, Day) VALUES('%i', '%i', '%s', '%s', '%d', '%d', '%d')",
                PlayerInfo[playerid][cSQLID], SendingTo, subb,str, Year, Month, Day);
            mysql_query(query);
            SendClientMessage(playerid, 0xFFFF0096, "{B7F205}INFO:{FFFFFF} Email sent!");
            EmailBusy = 0;
            return 1;
        }
        case DIALOG_SHOW_EMAIL:
        {
			if(!response) return ShowPlayerDialog(playerid, LAPTOP_DIALOG, DIALOG_STYLE_LIST, "Laptop", "- Send E-Mail\n- Check E-Mail\n- Goto Adress\n- Create my website\n- Edit my website\n- Poogle", "Select", "Shut Down");
            new ClickedSubject[64];
            new Body[128] , Sender, EmailSubject2[64];
            new SendingTo2;
            new Year, Month, Day;
            new id;
            format(ClickedSubject,64 ,inputtext[strfind(inputtext,"id:")+3]);
            format(query, sizeof(query), "SELECT * FROM email WHERE SQLid = '%i'", strval(ClickedSubject));
            mysql_query(query);
            mysql_store_result();
            while(mysql_fetch_row_format(line,"|")) {
                sscanf(line, "p<|>diis[64]s[128]ddd", id, Sender,SendingTo2, EmailSubject2, Body, Year, Month, Day );
                if(PlayerInfo[playerid][cSQLID] == SendingTo2)
				{
                    format(line, sizeof(line), "{05F2EE}From:{FFFFFF} %s\n{05F2EE}To: {FFFFFF}%s\n{05F2EE}Subject: {FFFFFF}%s\n{05F2EE}Date: {FFFFFF}%d/%d/%d\n\n%s", GetUserDBName(Sender),GetUserDBName(SendingTo2), EmailSubject2,Year, Month, Day, Body);
                    ShowPlayerDialog(playerid, DIALOG_SHOWING_EMAIL_BODY, DIALOG_STYLE_MSGBOX, "Internet Browser", line, "Options", "Back");
					SetPVarInt(playerid, "BROWSE_EMAIL", strval(ClickedSubject));
				}
            }
		 }
		 case DIALOG_SHOWING_EMAIL_BODY:
		 {
			if(!response) return ShowEmails(playerid);
			ShowPlayerDialog(playerid, DIALOG_SHOWING_EMAIL_OPTIONS, DIALOG_STYLE_LIST, "{00FFAA}E-Mail Options", "Delete this email{F73E7F}({FFFFFF}Cannot be restored{F73E7F}){FFFFFF}\nBack", "Select", "");
			return true;
		 }
		 case DIALOG_SHOWING_EMAIL_OPTIONS:
		 {
		    if(!response) return ShowEmails(playerid);
		    if(listitem == 1)
		    {
               ShowEmails(playerid);
               return true;
			}
			format(query, sizeof(query), "DELETE FROM email WHERE SQLid = %i LIMIT 1", GetPVarInt(playerid, "BROWSE_EMAIL"));
 		    mysql_query(query);
			ShowEmails(playerid);
			return true;
		 }
		 case DIALOG_WEBSITE_LIST:
		 {
		    if(!response) return ShowPlayerDialog(playerid, LAPTOP_DIALOG, DIALOG_STYLE_LIST, "Laptop", "- Send E-Mail\n- Check E-Mail\n- Goto Adress\n- Create my website\n- Edit my website\n- Poogle", "Select", "Shut Down");
            format(query, sizeof(query), "SELECT WebAdress, OwnerName, Content FROM webpages WHERE WebAdress = '%s'", inputtext);
            mysql_query(query, THREAD_SHOW_WEB, playerid);
            return true;
         }
         case DIALOG_GPS_MENU:
         {
			if(!response) return ShowInventory(playerid);
            format(query, sizeof(query), "SELECT Place,X,Y,Z FROM gps WHERE Place = '%s'", inputtext);
            mysql_query(query, THREAD_SHOW_LOCATION, playerid);
            return true;
		 }
		 case DIALOG_PHONE_MENU:
		 {
			if(!response) return true;

			switch(listitem)
			{
				case 0:
				{
					 ShowPlayerDialog(playerid, DIALOG_PHONE_CALL, DIALOG_STYLE_INPUT, "Cellphone", "{FFFFFF}Enter the number you wish to call", "Call", "Back");
					 return true;
			    }
			    case 1:
			    {
     		         format(query, sizeof(query), "SELECT sqlid, Name, Number FROM phone_contacts WHERE id = '%i'", PlayerInfo[playerid][cSQLID]);
   				     mysql_query(query, THREAD_CONTACTS_LIST, playerid);
   				     return true;
				}
				case 2:
		        {
						ShowPlayerDialog(playerid, DIALOG_PHONE_SMS2, DIALOG_STYLE_INPUT, "SMS", "Type in cellphone number to what you wish to send this SMS", "Next", "Back");
						return  true;
		        }
			 }
	      }
	      case DIALOG_PHONE_CALL:
	      {
			if(!response)
			{
					 new string[64];
		 			 format(string, 64, "{33CCFF}Phone number:{FFFFFF} %i", PlayerInfo[playerid][pNumber]);
		 			 ShowPlayerDialog(playerid,	DIALOG_PHONE_MENU, DIALOG_STYLE_LIST, string, "Call\nView Contacts\nSMS", "Select", "Close");
					 return true;
			}
			if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_PHONE_CALL, DIALOG_STYLE_INPUT, "Cellphone", "{FFFFFF}Enter the number you wish to call\n{FF6633}ERROR:{FFFFFF} Invalid phone number.", "Call", "Back");
			if(strval(inputtext) == PlayerInfo[playerid][pNumber]) return ShowPlayerDialog(playerid, DIALOG_PHONE_CALL, DIALOG_STYLE_INPUT, "Cellphone", "{FFFFFF}Enter the number you wish to call\n{FF6633}ERROR:{FFFFFF} Invalid phone number.", "Call", "Back");
			new is;
			foreach(Player, i)
			{
				if(PlayerInfo[i][pNumber] == strval(inputtext))
				{
					 if(GetPVarInt(i, "CALLING_TO") > -1)
					 {
						SendClientMessage(playerid, COLOR_GREY, "You get a busy tone...");
					    new string[64];
	 			        format(string, 64, "{33CCFF}Phone number:{FFFFFF} %i", PlayerInfo[playerid][pNumber]);
	 			        ShowPlayerDialog(playerid,	DIALOG_PHONE_MENU, DIALOG_STYLE_LIST, string, "Call\nView Contacts\nSMS", "Select", "Close");
						SetPVarInt(playerid, "CALLING_TO", -1);
						break;
					 }
					 is ++;
					 SetPVarInt(playerid, "CALLING_TO", i);
					 SetPVarInt(i, "CALLING_TO", playerid);
				}
			}
			if(is == 0)
			{
					SendClientMessage(playerid, COLOR_GREY, "You get a busy tone...");
					new string[64];
	 			    format(string, 64, "{33CCFF}Phone number:{FFFFFF} %i", PlayerInfo[playerid][pNumber]);
	 			    ShowPlayerDialog(playerid,	DIALOG_PHONE_MENU, DIALOG_STYLE_LIST, string, "Call\nView Contacts\nSMS", "Select", "Close");
					SetPVarInt(playerid, "CALLING_TO", -1);
					return true;
			}
			new id = GetPVarInt(playerid, "CALLING_TO");
			SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
			SetPlayerSpecialAction(id, SPECIAL_ACTION_USECELLPHONE);
            GetPlayerName(id, PlayerName, sizeof(PlayerName));
            format(str, sizeof(str), "* Phone rings (( %s ))", PlayerName);
            SendLocalMessage(id, str, 20.0, 0x83bfbfAA);
            ShowInfo(playerid, "type ~y~/hangup~w~ to hangup the call");
            ShowPlayerDialog(id, DIALOG_PHONE_OPTION, DIALOG_STYLE_MSGBOX, "Phone", "{FFFFFF}Someone is calling you, you must pickup the call or hangup", "Pickup", "Hangup");
            return true;
		  }
		  case DIALOG_PHONE_OPTION:
		  {
			if(!response)
			{
			   new id = GetPVarInt(playerid, "CALLING_TO");
			   SendClientMessage(id, COLOR_GREY, "They hangup the call...");
			   SetPlayerSpecialAction(id, SPECIAL_ACTION_STOPUSECELLPHONE);
			   SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
		       SetPVarInt(playerid, "CALLING_TO", -1);
		       SetPVarInt(id, "CALLING_TO", -1);
		       SetPVarInt(playerid, "ON_PHONE", 0);
		       SetPVarInt(id, "ON_PHONE", 0);
		       return true;
			}
			else
			{
			   new id = GetPVarInt(playerid, "CALLING_TO");
			   SendClientMessage(id, COLOR_GREY, "They picked up the call...");
		       SetPVarInt(playerid, "ON_PHONE", 1);
		       SetPVarInt(id, "ON_PHONE", 1);
		       return true;
			}
          }
          case DIALOG_CONTACTS_LIST:
          {
			if(!response)
			{
					 new string[64];
		 			 format(string, 64, "{33CCFF}Phone number:{FFFFFF} %i", PlayerInfo[playerid][pNumber]);
		 			 ShowPlayerDialog(playerid,	DIALOG_PHONE_MENU, DIALOG_STYLE_LIST, string, "Call\nView Contacts\nSMS", "Select", "Close");
					 return true;
			}
			if(listitem == 0)
			{
     		         format(query, sizeof(query), "SELECT sqlid, Name, Number FROM phone_contacts WHERE id = '%i'", PlayerInfo[playerid][cSQLID]);
   				     mysql_query(query, THREAD_CONTACTS_LIST, playerid);
   				     return true;
			}
            if(!strcmp(inputtext,"\tAdd new contact",true))
            {
				    ShowPlayerDialog(playerid, DIALOG_CONTACTS_ADD, DIALOG_STYLE_INPUT, "Add contact", "{FFFFFF}Type in the contact's name you wish to add.", "Next", "Back");
					return true;
			}
			new click[6];
			format(click,6 ,inputtext[strfind(inputtext,"(id:")+4]);
			new query[256];
			new name[24];
			new id;
			new number;
			format(query, sizeof(query), "SELECT Name, Number, id FROM phone_contacts WHERE sqlid = '%i' LIMIT 0,1", strval(click));
			mysql_query(query);
			mysql_store_result();
			mysql_fetch_row_format(line);
			sscanf(line, "p<|>s[24]ii", name, number, id);
			mysql_free_result();
			new lol;
			foreach(Player, i)
			{
			   if(PlayerInfo[i][pNumber] == number)
			   {
					 lol ++;
			   }
			}
			if(lol == 0)
			{
					 new string[64];
		 			 format(string, 64, "{33CCFF}Contact %s", name);
		 			 ShowPlayerDialog(playerid, DIALOG_CONTACTS_OPTION2, DIALOG_STYLE_LIST, string, "Delete from contacts", "Select", "Back");
					 SendClientMessage(playerid, COLOR_GREY, "This contact is not online or the number doesn't exist.");
					 SetPVarInt(playerid, "CLICKED_C", strval(click));
                     return true;
			}
			SetPVarInt(playerid, "CLICKED_C", strval(click));
			SetPVarInt(playerid, "CLICKED_N", number);
		    new string[64];
		    format(string, 64, "{33CCFF}Contact %s", name);
			ShowPlayerDialog(playerid, DIALOG_CONTACTS_OPTION, DIALOG_STYLE_LIST, string, "Call\nWrite text message\nDelete from contacts", "Select", "Back");
			return true;
		  }
		  case DIALOG_CONTACTS_OPTION:
		  {
			if(!response)
			{
     		         format(query, sizeof(query), "SELECT sqlid, Name, Number FROM phone_contacts WHERE id = '%i'", PlayerInfo[playerid][cSQLID]);
   				     mysql_query(query, THREAD_CONTACTS_LIST, playerid);
   				     return true;
			}
			switch(listitem)
			{
				  case 0:
				  {
						new number = GetPVarInt(playerid, "CLICKED_N");
						foreach(Player, i)
						{
							if(PlayerInfo[i][pNumber] == number)
							{
								 if(GetPVarInt(i, "CALLING_TO") > -1)
								 {
									SendClientMessage(playerid, COLOR_GREY, "You get a busy tone...");
								    new string[64];
				 			        format(string, 64, "{33CCFF}Phone number:{FFFFFF} %i", PlayerInfo[playerid][pNumber]);
				 			        ShowPlayerDialog(playerid,	DIALOG_PHONE_MENU, DIALOG_STYLE_LIST, string, "Call\nView Contacts\nSMS", "Select", "Close");
									SetPVarInt(playerid, "CALLING_TO", -1);
									break;
								 }
								 SetPVarInt(playerid, "CALLING_TO", i);
								 SetPVarInt(i, "CALLING_TO", playerid);
							}
						}
						new id = GetPVarInt(playerid, "CALLING_TO");
						SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
						SetPlayerSpecialAction(id, SPECIAL_ACTION_USECELLPHONE);
			            GetPlayerName(id, PlayerName, sizeof(PlayerName));
			            format(str, sizeof(str), "* Phone rings (( %s ))", PlayerName);
			            SendLocalMessage(id, str, 20.0, 0x83bfbfAA);
			            ShowInfo(playerid, "type ~y~/hangup~w~ to hangup the call");
			            ShowPlayerDialog(id, DIALOG_PHONE_OPTION, DIALOG_STYLE_MSGBOX, "Phone", "{FFFFFF}Someone is calling you, you must pickup the call or hangup", "Pickup", "Hangup");
						DeletePVar(playerid, "CLICKED_N");
						return true;
				  }
				  case 1:
				  {
						ShowPlayerDialog(playerid, DIALOG_PHONE_SMS, DIALOG_STYLE_INPUT, "SMS", "Type in the text message you wish to send.", "Next", "Back");
						return  true;
				  }
				  case 2:
				  {
						format(query, sizeof(query), "DELETE FROM phone_contacts WHERE sqlid = '%i' LIMIT 1", GetPVarInt(playerid, "CLICKED_C"));
		        		mysql_query(query);
     		         	format(query, sizeof(query), "SELECT sqlid, Name, Number FROM phone_contacts WHERE id = '%i'", PlayerInfo[playerid][cSQLID]);
   				     	mysql_query(query, THREAD_CONTACTS_LIST, playerid);
   				     	SendClientMessage(playerid, COLOR_YELLOW, "Phone contact has been succesfully deleted.");
   				     	return true;
				   }
			}
		  }
		  case DIALOG_CONTACTS_OPTION2:
		  {
			if(!response)
			{
     		         format(query, sizeof(query), "SELECT sqlid, Name, Number FROM phone_contacts WHERE id = '%i'", PlayerInfo[playerid][cSQLID]);
   				     mysql_query(query, THREAD_CONTACTS_LIST, playerid);
   				     return true;
			}
			format(query, sizeof(query), "DELETE FROM phone_contacts WHERE sqlid = '%i' LIMIT 1", GetPVarInt(playerid, "CLICKED_C"));
 		    mysql_query(query);
      	    format(query, sizeof(query), "SELECT sqlid, Name, Number FROM phone_contacts WHERE id = '%i'", PlayerInfo[playerid][cSQLID]);
	     	mysql_query(query, THREAD_CONTACTS_LIST, playerid);
	     	SendClientMessage(playerid, COLOR_YELLOW, "{FFFD96}INFO:{FFFFFF}Phone contact has been succesfully deleted.");
			return true;
		  }
		  case DIALOG_PHONE_SMS:
		  {
				   if(!response)
				   {
							 new string[64];
				 			 format(string, 64, "{33CCFF}Phone number:{FFFFFF} %i", PlayerInfo[playerid][pNumber]);
				 			 ShowPlayerDialog(playerid,	DIALOG_PHONE_MENU, DIALOG_STYLE_LIST, string, "Call\nView Contacts\nSMS", "Select", "Close");
							 return true;
				   }
				   if(GetPlayerMoney(playerid) < 1) return SendClientMessage(playerid, COLOR_RED, "You can't afford this.");
				   new number = GetPVarInt(playerid, "CLICKED_C");
				   new id = -1;
				   foreach(Player, i)
				   {
						 if(PlayerInfo[i][pNumber] == number)
						 {
								  id = i;
								  break;
						 }
				   }
				   GivePlayerMoney(playerid, -1);
				   new sms_str[128];
				   GetPlayerName(playerid, PlayerName, 24);
				   format(sms_str, 128, "{33FFCC}SMS FROM %s:{FFFFFF}%s", PlayerName, inputtext);
				   SendClientMessage(id, COLOR_WHITE, sms_str);
				   GetPlayerName(id, PlayerName, 24);
				   format(sms_str, 128, "{33FFCC}SMS SENT TO %s:{FFFFFF}%s", PlayerName, inputtext);
				   SendClientMessage(id, COLOR_WHITE, sms_str);
				   return true;
		   }
		   case DIALOG_PHONE_SMS2:
		   {
				   if(!response)
				   {
							 new string[64];
				 			 format(string, 64, "{33CCFF}Phone number:{FFFFFF} %i", PlayerInfo[playerid][pNumber]);
				 			 ShowPlayerDialog(playerid,	DIALOG_PHONE_MENU, DIALOG_STYLE_LIST, string, "Call\nView Contacts\nSMS", "Select", "Close");
							 return true;
				   }
				   
				   if(!IsNumeric(inputtext))
				   {
						ShowPlayerDialog(playerid, DIALOG_PHONE_SMS2, DIALOG_STYLE_INPUT, "SMS", "Type in cellphone number to what you wish to send this SMS", "Next", "Back");
						return  true;
		           }
		           new pl;
		           new id;
		           foreach(Player, i)
		           {
						if(PlayerInfo[i][pNumber] == strval(inputtext))
						{
							id ++;
							pl = i;
						}
				   }
				   if(id == 0)
				   {
						ShowPlayerDialog(playerid, DIALOG_PHONE_SMS2, DIALOG_STYLE_INPUT, "SMS", "Type in cellphone number to what you wish to send this SMS\n{FF0000}ERROR:{FFFFFF}Invalid cellphone number.", "Next", "Back");
						return  true;
		           }
		           SetPVarInt(playerid, "SMS_TO", pl);
                   ShowPlayerDialog(playerid, DIALOG_PHONE_SMS3, DIALOG_STYLE_INPUT, "SMS", "Type in the message you wish to send.", "Send", "Back");
		           return true;
		   }
		   case DIALOG_PHONE_SMS3:
		   {
				   if(!response)
				   {
							 new string[64];
				 			 format(string, 64, "{33CCFF}Phone number:{FFFFFF} %i", PlayerInfo[playerid][pNumber]);
				 			 ShowPlayerDialog(playerid,	DIALOG_PHONE_MENU, DIALOG_STYLE_LIST, string, "Call\nView Contacts\nSMS", "Select", "Close");
							 return true;
				   }
				   new id = GetPVarInt(playerid, "SMS_TO");
				   new sms_str[128];
				   GetPlayerName(playerid, PlayerName, 24);
				   format(sms_str, 128, "{33FFCC}SMS FROM %s:{FFFFFF}%s", PlayerName, inputtext);
				   SendClientMessage(id, COLOR_WHITE, sms_str);
				   GetPlayerName(id, PlayerName, 24);
				   format(sms_str, 128, "{33FFCC}SMS SENT TO %s:{FFFFFF}%s", PlayerName, inputtext);
				   SendClientMessage(id, COLOR_WHITE, sms_str);
				   return true;
			}
			case DIALOG_CONTACTS_ADD:
			{
				   if(!response)
				   {
							 new string[64];
				 			 format(string, 64, "{33CCFF}Phone number:{FFFFFF} %i", PlayerInfo[playerid][pNumber]);
				 			 ShowPlayerDialog(playerid,	DIALOG_PHONE_MENU, DIALOG_STYLE_LIST, string, "Call\nView Contacts\nSMS", "Select", "Close");
							 return true;
				   }
				   if(strlen(inputtext) < 1)
				   {
							 new string[64];
				 			 format(string, 64, "{33CCFF}Phone number:{FFFFFF} %i", PlayerInfo[playerid][pNumber]);
				 			 ShowPlayerDialog(playerid,	DIALOG_PHONE_MENU, DIALOG_STYLE_LIST, string, "Call\nView Contacts\nSMS", "Select", "Close");
							 return true;
				   }
				   SetPVarString(playerid, "ADDING", inputtext);
				   ShowPlayerDialog(playerid, DIALOG_CONTACTS_ADD2, DIALOG_STYLE_INPUT, "Add contact", "Type in contact's number you wish to add.", "Add", "Cancel");
		    }
			case DIALOG_CONTACTS_ADD2:
			{
				   if(!response)
				   {
							 new string[64];
				 			 format(string, 64, "{33CCFF}Phone number:{FFFFFF} %i", PlayerInfo[playerid][pNumber]);
				 			 ShowPlayerDialog(playerid,	DIALOG_PHONE_MENU, DIALOG_STYLE_LIST, string, "Call\nView Contacts\nSMS", "Select", "Close");
							 DeletePVar(playerid, "ADDING");
							 return true;
				   }
				   if(strlen(inputtext) < 1)
				   {
							 new string[64];
				 			 format(string, 64, "{33CCFF}Phone number:{FFFFFF} %i", PlayerInfo[playerid][pNumber]);
				 			 ShowPlayerDialog(playerid,	DIALOG_PHONE_MENU, DIALOG_STYLE_LIST, string, "Call\nView Contacts\nSMS", "Select", "Close");
                             DeletePVar(playerid, "ADDING");
							 return true;
				   }
				   if(!IsNumeric(inputtext))
				   {
                        ShowPlayerDialog(playerid, DIALOG_CONTACTS_ADD2, DIALOG_STYLE_INPUT, "Add contact", "Type in contact's number you wish to add.\nERROR: Invalid number.", "Add", "Cancel");
						return true;
				   }
				   new cont_name[24];
				   GetPVarString(playerid, "ADDING", cont_name, 24);
				   DeletePVar(playerid, "ADDING");
	   			   format(query, sizeof(query), "INSERT INTO phone_contacts (Name, Number, id) VALUES ('%s', '%i', '%i')", cont_name, strval(inputtext), PlayerInfo[playerid][cSQLID]);
			       mysql_query(query);
     	           format(query, sizeof(query), "SELECT sqlid, Name, Number FROM phone_contacts WHERE id = '%i'", PlayerInfo[playerid][cSQLID]);
	     	       mysql_query(query, THREAD_CONTACTS_LIST, playerid);
	     	       SendClientMessage(playerid, COLOR_YELLOW, "{FFFD96}INFO:{FFFFFF}Phone contact has been succesfully added.");
				   return true;
			 }
	}
	return true;
}

public OnVehicleSpawn(vehicleid)
{
    SetVehiclePos(vehicleid, VehicleInfo[vehicleid][vPos][0], VehicleInfo[vehicleid][vPos][1], VehicleInfo[vehicleid][vPos][2]);
    SetVehicleZAngle(vehicleid, VehicleInfo[vehicleid][vPos][3]);
    ModVehicle(vehicleid);
    return 1;
}

public OnVehicleMod(playerid, vehicleid,componentid)
{
    if(componentid == 1008) { RemoveVehicleComponent(vehicleid,1008); return 1; } // disable nitro
    if(componentid == 1009) { RemoveVehicleComponent(vehicleid,1009); return 1; } // disable nitro
    if(componentid == 1010) { RemoveVehicleComponent(vehicleid,1010); return 1; } // disable nitro
    SaveComponent(playerid, vehicleid, componentid);
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	VehicleInfo[vehicleid][vcolor1] = color1;
	VehicleInfo[vehicleid][vcolor2] = color2;
    return 1;
}

public OnQueryFinish(finished_query[], resultid, extraid, connectionHandle)
{
	new t_line[512], t_str[128], t_tmp[256];
	switch(resultid)
    {
        case THREAD_CHARS_MENU:
        {
     		mysql_store_result();
	 		new charID, charCount;
			if(mysql_num_rows() != 0)
			{
				while(mysql_fetch_row_format(t_line, "|"))
				{
					charCount ++;
					sscanf(t_line, "p<|>is[24]", charID, t_str);
					strcat(t_tmp, t_str);
					strcat(t_tmp, "\n");
				}
			}
			mysql_free_result();
     		if(!charCount)
     		{
				t_tmp = "- No created characters! -\n- To create a character, go to Options -";
	 		}
	 		SetPVarInt(extraid, "CHAR_COUNT", charCount);
			if(GetPVarType(extraid, "DELETING") == PLAYER_VARTYPE_INT)
				return ShowPlayerDialog(extraid, DIALOG_CHAR, DIALOG_STYLE_LIST, "Main menu - Characters", t_tmp, "Cancel deleting", "Delete"), true;

			ShowPlayerDialog(extraid, DIALOG_CHAR, DIALOG_STYLE_LIST, "Main menu - Characters", t_tmp, "Options", "Spawn");
			return 1;
		}
		case LOGIN_MENU:
		{
			mysql_store_result();
            ShowLogBox(extraid);
            
            SendClientMessage(extraid, 0x00FF9DFF, "{E80FCC}SERVER: {FFFFFF}Welcome to Andreas Role Play "#VERSION"");

			tmp = "Account: {F4C60F}";
			strcat(tmp, PlayerName);

			str = "{FAFFFF}Welcome to Andreas-Roleplay, ";
			strcat(str, PlayerName);
			strcat(str, "!\nYour username is ");

			if(mysql_num_rows() == 1)
			{
                new
                	p_IP[20];

                TogglePlayerSpectating(extraid,1);
            	GetPlayerIp(extraid, p_IP, 20);
            	GetPlayerName(extraid, PlayerName, 20);
            	format(t_str, sizeof(t_str), "SELECT id FROM accounts WHERE name = '%s' AND ip = '%s' AND AutoLogin = 1", PlayerName, p_IP);
            	mysql_query(t_str);
            	mysql_store_result();
            	if(mysql_num_rows()) // AUTO LOGIN
            	{
                    PlayerInfo[extraid][pSQLID] = mysql_fetch_int();
            	    SendClientMessage(extraid, 0xFF0000FF, "{FFFD96}INFO:{FFFFFF} You have been auto logged in.");
                	SendClientMessage(extraid, 0xFF0000FF, "{FFFD96}INFO:{FFFFFF} Auto login is {FFFD96}enabled{FFFFFF}, to disable it go to Account Settings.");
                	ShowCharactersMenu(extraid);
                	SetPVarInt(extraid, "AUTO_LOG", 1);
                	return mysql_free_result();
            	}
                mysql_free_result();
				// registered
				strcat(str, "registered. If this account is yours,\ntype in your password now and click \"Login\"");
				strcat(tmp, " {FFFFFF}(log in)");
				// TO-DO: a future implementation should check if the player can be logged in automatically?

				ShowPlayerDialog(extraid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, tmp, str, "Login", "");
			}
			else
			{
				// not registered
				strcat(str, "not registered. If you want to register it,\ntype in your password now and click \"Register\"");
				strcat(tmp, " {FFFFFF}(register)");
				ShowPlayerDialog(extraid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, tmp, str, "Register", "");
			}
			mysql_free_result();
			gHasCharacters{extraid} = true;
		 }
		 case THREAD_FIGHTINGSTYLE:
		 {
			mysql_store_result();
			new cid, id, fight_dialog[128];
			fight_dialog = "{FFBF00}Normal";
			if(mysql_num_rows() != 0)
			{
				while(mysql_fetch_row_format(t_line, "|"))
				{
					sscanf(t_line, "p<|>{i}ii", id, cid);
					if(cid == 5)
					{
						format(fight_dialog, 128, "%s\nBoxing", fight_dialog);
					}
					if(cid == 6)
					{
						format(fight_dialog, 128, "%s\nKungFu", fight_dialog);
					}
					if(cid == 15)
					{
						format(fight_dialog, 128, "%s\nGrabKick", fight_dialog);
					}
					if(cid == 26)
					{
						format(fight_dialog, 128, "%s\nElbow", fight_dialog);
					}
				}
			}
			ShowPlayerDialog(extraid, DIALOG_FIGHTING_STYLES, DIALOG_STYLE_LIST, "Your fighting styles", fight_dialog, "Use", "Exit");
			mysql_free_result();
		 }
		 case THREAD_EMAILS:
		 {
            mysql_store_result();
            new EmailSubject2[64];
            new id;
            new mailcount = 0;
            EmailList = "";
            while(mysql_fetch_row_format(line,"|"))
			{
			       sscanf(line, "p<|>is[64]", id, EmailSubject2);
			       format(EmailList,sizeof(EmailList),"%s\n{05C7F2}Subject: {FFFFFF}%s {68D6F7}(id:%i){FFFFFF}",EmailList, EmailSubject2, id);
			       mailcount ++;
		    }
            if(mailcount == 0)
            {
		   		   ShowPlayerDialog(extraid, 9999, DIALOG_STYLE_MSGBOX, "Internet Explorer", "You have no mail", "Okay", "Cancel");
		   		   return true;
		    }
	        if(mailcount == 30)
	        {
				   ShowInfo(extraid, "Your e-mail is ~r~FULL!~w~You should delete some e-mails. ( MAX 30 )");
	        }
			ShowPlayerDialog(extraid, DIALOG_SHOW_EMAIL, DIALOG_STYLE_LIST, "Internet Browser", EmailList, "Select", "Back");
   			mysql_free_result();
            return 1;
          }
          case THREAD_WEBSITE_LIST:
          {
             mysql_store_result();
             if(!mysql_num_rows()) return ShowPlayerDialog(extraid, 9999, DIALOG_STYLE_MSGBOX, "Internet Explorer", "No websites found", "Okay", ""), mysql_free_result();
			 EmailList = "";
			 while(mysql_fetch_row_format(line,"|"))
			 {
			      format(EmailList,sizeof(EmailList),"%s\n%s",EmailList, line);
			 }
			 new header[45];
			 format(header, 45, "Poogle - %i results found", mysql_num_rows() );
			 ShowPlayerDialog(extraid, DIALOG_WEBSITE_LIST, DIALOG_STYLE_LIST, header, EmailList, "Enter", "Back");
			 mysql_free_result();
			 return true;
		  }
		  case THREAD_SHOW_WEB:
		  {
             mysql_store_result();
             if(!mysql_num_rows()) return ShowPlayerDialog(extraid, 9999, DIALOG_STYLE_MSGBOX, "Internet Explorer", "404 error - website not found", "Okay", ""), mysql_free_result();
			 new webname[24];
			 new ownername;
			 mysql_fetch_row_format(line,"|");
             sscanf(line, "p<|>s[24]s[24]s[256]", webname, ownername, t_tmp);
			 mysql_free_result();
             new string[512];
             format(string, sizeof(string), "{FFFFFF}%s\n Web Site is registered to - {FFBF00}%s", t_tmp, GetUserDBName(ownername));
             ShowPlayerDialog(extraid, DIALOG_WEB_CONTENT, DIALOG_STYLE_MSGBOX, webname, string, "Exit", "");
             return true;
		  }
		  case THREAD_EDIT_WEB:
		  {
             mysql_store_result();
			 new webname[24];
			 new ownername;
			 mysql_fetch_row_format(line,"|");
             sscanf(line, "p<|>s[24]s[24]s[256]", webname, ownername, t_tmp);
             mysql_free_result();
             new string[512];
             format(string, sizeof(string), "{FFFFFF}%s\n Web Site is registered to - {FFBF00}%s", t_tmp, GetUserDBName(ownername));
             ShowPlayerDialog(extraid, DIALOG_WEB_EDIT2, DIALOG_STYLE_INPUT, webname, string, "Exit", "");
             return true;
		  }
		  case THREAD_GPS_SHOW:
		  {
             mysql_store_result();
             new placename[24];
			 while(mysql_fetch_row_format(t_line, "|"))
			 {
                sscanf(t_line, "p<|>s[24]", placename);
				strcat(t_tmp, placename);
				strcat(t_tmp, "\n");
			 }
 			 mysql_free_result();
 			 ShowPlayerDialog(extraid, DIALOG_GPS_MENU, DIALOG_STYLE_LIST, "GPS", t_tmp, "Okay", "Back");
			 return true;
	      }
	      case THREAD_SHOW_LOCATION:
	      {
             mysql_store_result();
             new placename[24];
             new Float:xx, Float:yy, Float:zz;
			 mysql_fetch_row_format(t_line, "|");
             sscanf(t_line, "p<|>s[24]fff", placename, xx, yy, zz);
             SetPlayerCheckpoint(extraid, xx, yy, zz, 2.0);
             new f_str[128];
			 format(f_str, 128, "{FF0000}Marker{FFFFFF} to %s has been set.", placename);
             ShowPlayerDialog(extraid, 9999, DIALOG_STYLE_MSGBOX, "GPS", f_str, "Close", "");
             mysql_free_result();
             SetPVarInt(extraid, "GPS_C", 1);
             return true;
		  }
		  case THREAD_CONTACTS_LIST:
		  {
             mysql_store_result();
             if(!mysql_num_rows())
             {
				ShowPlayerDialog(extraid, DIALOG_CONTACTS_LIST, DIALOG_STYLE_LIST, "Contacts list", "Add new contact", "Select", "Back");
				mysql_free_result();
				return true;
			 }
			 new number, cname[24];
			 new id;
			 EmailList = "\tContact Name\t\tNumber";
			 while(mysql_fetch_row_format(line,"|"))
			 {
                  sscanf(line, "p<|>is[24]i", id, cname, number);
			      format(EmailList,sizeof(EmailList),"%s\n\t%s\t\t%i{000000}(id:%i)",EmailList, cname, number, id );
			 }
			 format(EmailList,sizeof(EmailList),"%s\n\tAdd new contact", EmailList);
			 ShowPlayerDialog(extraid, DIALOG_CONTACTS_LIST, DIALOG_STYLE_LIST, "Cellphone", EmailList, "Select", "Back");
			 return true;
		   }
	}
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	if(GetPVarInt(playerid, "GPS_C") == 1)
	{
    	GameTextForPlayer(playerid, "~b~Location reached", 3000, 5);
    	DisablePlayerCheckpoint(playerid);
	}
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	   if(newkeys == KEY_FIRE && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
	   {
	      if(GetPVarInt(playerid, "VEHICLE_CPU") == 2)
		  {
			 TextDrawDestroy(HouseTitle[playerid]);
			 TextDrawDestroy(HouseMenu[playerid]);
			 HouseTitle[playerid] = Text:INVALID_TEXT_DRAW;
			 HouseMenu[playerid] = Text:INVALID_TEXT_DRAW;
			 SetPVarInt(playerid, "VEHICLE_CPU", 0);
			 SetPVarInt(playerid, "VEHICLE_OPTION", 0);
			 TogglePlayerControllable(playerid, true);
		  }
	   }
	   if(newkeys == KEY_FIRE && IsPlayerInAnyVehicle(playerid))
	   {
	      new    VehID = GetPlayerVehicleID(playerid);
		  if(GetPVarInt(playerid, "VEHICLE_CPU") == 1)
		  {
			 TextDrawDestroy(VehName[playerid]);
			 TextDrawDestroy(SpeedHud[playerid]);
			 VehName[playerid]  = Text:INVALID_TEXT_DRAW;
			 SpeedHud[playerid] = Text:INVALID_TEXT_DRAW;
			 SetPVarInt(playerid, "VEHICLE_CPU", 0);
			 SetPVarInt(playerid, "VEHICLE_OPTION", 0);
			 TogglePlayerControllable(playerid, true);
			 return true;
		  }
	      if(VehicleInfo[VehID][vEngine] == 0)
	      {
		 	   if(VehicleInfo[VehID][vOwner] > 0 && VehicleInfo[VehID][vOwner] != PlayerInfo[playerid][cSQLID] && VehicleInfo[VehID][vbuyable] == 1 && VehicleInfo[VehID][vRented] != PlayerInfo[playerid][cSQLID])
			   {
			     SendClientMessage(playerid, COLOR_GREY, "You don't have keys for this vehicle");
			     return true;
			   }
			   VehicleInfo[VehID][vEngine] = 1;
			   
			   new
			        engine,
			   		light,
			    	alarm,
					doors,
					bonnet,
					boot,
					objective;
					
     	       GetVehicleParamsEx(VehID, engine,light,alarm,doors,bonnet,boot,objective);
               SetVehicleParamsEx(VehID,VEHICLE_PARAMS_ON,light,alarm,doors,bonnet,boot,objective);
           	   GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	           new VehicleName[24];
   	           GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
               format(str, sizeof(str), "%s attempts to start %s engine.", PlayerName, VehicleName );
	           SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
               format(str, sizeof(str), "%s engine starts (( %s ))", VehicleName, PlayerName );
	           SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
			   return true;
		  }
		  return true;
	   }
       if(newkeys == KEY_WALK)
	   {
			if(IsPlayerInAnyVehicle(playerid)) return true;
	        if(GetPVarInt(playerid, "Building") > -1)
			{
	            new buildingid = GetPVarInt(playerid, "Building");
	            if(IsPlayerInRangeOfPoint(playerid, 2, BuildingCoords[BuildingInfo[buildingid][bbInterior]][0], BuildingCoords[BuildingInfo[buildingid][bbInterior]][1], BuildingCoords[BuildingInfo[buildingid][bbInterior]][2]))
				{
	                SetPlayerPos(playerid, BuildingInfo[buildingid][bbPos][0], BuildingInfo[buildingid][bbPos][1], BuildingInfo[buildingid][bbPos][2]);
	                SetPVarInt(playerid, "Building", -1);
	                SetPlayerInterior(playerid, 0);
	                SetPlayerVirtualWorld(playerid, 0);
	                return 1;
	            }
            }
	   		foreach(Buildings, bb)
	        {
	            if(IsPlayerInRangeOfPoint(playerid, 2, BuildingInfo[bb][bbPos][0], BuildingInfo[bb][bbPos][1], BuildingInfo[bb][bbPos][2]))
				{
	                new Level = BuildingInfo[bb][bbInterior];
	                SetPlayerPos(playerid, BuildingCoords[Level][0], BuildingCoords[Level][1], BuildingCoords[Level][2]);
	                SetPlayerInterior(playerid, floatround(BuildingCoords[Level][3])); SetPlayerVirtualWorld(playerid, bb);
	                SetPVarInt(playerid, "Building", bb);
	                return 1;
	            }
	        }
	        
			foreach(Businesses, b)
			{
	            if(IsPlayerInRangeOfPoint(playerid, 5,  BusinessCoords[BusinessInfo[b][binterior]][0], BusinessCoords[BusinessInfo[b][binterior]][1], BusinessCoords[BusinessInfo[b][binterior]][2]))
				{
					new id = GetPVarInt(playerid, "BUSINESS");
                	SetPlayerPos(playerid, BusinessInfo[id][bcoords][0], BusinessInfo[id][bcoords][1], BusinessInfo[id][bcoords][2]);
                	SetPlayerInterior(playerid, 0);
					SetPlayerVirtualWorld(playerid, 0);
					return true;
				}
			}
	        foreach(Businesses, b)
			{
	            if(IsPlayerInRangeOfPoint(playerid, 2, BusinessInfo[b][bcoords][0], BusinessInfo[b][bcoords][1], BusinessInfo[b][bcoords][2]))
				{
	                if(BusinessInfo[b][block] == 1)
					{
	                    ShowInfo(playerid, "Locked");
	                    return true;
	                }
	                new Level = BusinessInfo[b][binterior];
	                SetPlayerPos(playerid, BusinessCoords[Level][0], BusinessCoords[Level][1], BusinessCoords[Level][2]);
	                SetPlayerInterior(playerid, BusinessInteriors[Level][0]);
					SetPlayerVirtualWorld(playerid, b);
	                SetPVarInt(playerid, "BUSINESS", b);
	                SetPlayerVirtualWorld(playerid, b);
	                return true;
	            }
	        }
        	foreach(House, h)
			{
				    if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ]))
					{
		                if(HouseInfo[h][hLocked] == 0)
						{
		                    new Level = HouseInfo[h][hLevel];
		                    SetPlayerPos(playerid, HousesCoords[Level][0], HousesCoords[Level][1], HousesCoords[Level][2]);
		                    SetPlayerInterior(playerid, HousesLevels[Level][0]); SetPlayerVirtualWorld(playerid, HouseInfo[h][hVirtualWorld]);
		                    SetPlayerVirtualWorld(playerid, h);
		                    SetPVarInt(playerid, "HOUSE", h);
		                    return 1;
						}
						else
						{
							ShowInfo(playerid, "This house is ~r~locked!");
							return 1;
						}
					}
        	}
			for(new i = 0; i<14; i++)
			{
  				if(IsPlayerInRangeOfPoint(playerid, 2, HousesCoords[i][0], HousesCoords[i][1], HousesCoords[i][2]))
				{
				     new HouseId = GetPVarInt(playerid, "HOUSE");
     				 SetPlayerPos(playerid, HouseInfo[HouseId][hExitX], HouseInfo[HouseId][hExitY], HouseInfo[HouseId][hExitZ]);
         	         SetPlayerInterior(playerid, 0); SetPlayerVirtualWorld(playerid, 0);
         	         SetPVarInt(playerid, "HOUSE", 0);
				     return 1;
        	    }
           }
	   }
	   return true;
}
public OnPlayerUpdate(playerid)
{
	static
		s_iVehicle
	;

	if ( g_fSpeedCap[ playerid ] != 0.0 && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
	{
		s_iVehicle = GetPlayerVehicleID( playerid );

		if ( s_iVehicle )
		{
			static
				Float:s_fX,
				Float:s_fY,
				Float:s_fZ,
				Float:s_fVX,
				Float:s_fVY,
				Float:s_fVZ
			;

			GetVehiclePos( s_iVehicle, s_fX, s_fY, s_fZ );
			GetVehicleVelocity( s_iVehicle, s_fVX, s_fVY, s_fVZ );

			if ( !IsPlayerInRangeOfPoint( playerid, g_fSpeedCap[ playerid ] + 0.05, s_fX + s_fVX, s_fY + s_fVY, s_fZ + s_fVZ ) )
			{
				static
					Float:s_fLength
				;

				s_fLength = floatsqroot( ( s_fVX * s_fVX ) + ( s_fVY * s_fVY ) + ( s_fVZ * s_fVZ ) );

				s_fVX = ( s_fVX / s_fLength ) * g_fSpeedCap[ playerid ];
				s_fVY = ( s_fVY / s_fLength ) * g_fSpeedCap[ playerid ];
				s_fVZ = ( s_fVZ / s_fLength ) * g_fSpeedCap[ playerid ];

				if ( s_iVehicle )
					SetVehicleVelocity( s_iVehicle, s_fVX, s_fVY, s_fVZ );
				else
					SetPlayerVelocity( playerid, s_fVX, s_fVY, s_fVZ );
			}
		}
	}
	if(GetPVarInt(playerid, "BLOCKED") > 0) return true;
	if(GetPVarInt(playerid, "VEHICLE_CPU") == 1)
	{
        new Keys,ud,lr;
        GetPlayerKeys(playerid,Keys,ud,lr);
        if(ud > 0)
        {
			 if(GetPVarInt(playerid, "VEHICLE_OPTION") == 5)
			 {
				 return 1;
			 }
			 SetPVarInt(playerid, "VEHICLE_OPTION", GetPVarInt(playerid, "VEHICLE_OPTION") +1);
			 UpdateVehicleCPU(playerid);
			 SetPVarInt(playerid,  "BLOCKED", 3);
			 return true;
		}
    	if(ud < 0)
    	{
			 if(GetPVarInt(playerid, "VEHICLE_OPTION") == 1)
			 {
				 return 1;
			 }
			 SetPVarInt(playerid, "VEHICLE_OPTION", GetPVarInt(playerid, "VEHICLE_OPTION") -1);
			 UpdateVehicleCPU(playerid);
			 SetPVarInt(playerid,  "BLOCKED", 3);
			 return true;
	    }
	    GetPlayerName(playerid, PlayerName, 24);
	    new VehID = GetPlayerVehicleID(playerid);
	    new
			        engine,
			   		light,
			    	alarm,
					doors,
					bonnet,
					boot,
					objective;
        GetVehicleParamsEx(VehID, engine,light,alarm,doors,bonnet,boot,objective);
        if(GetPVarInt(playerid, "VEHICLE_OPTION") == 1)
        {
        	if(lr > 0)
			{
                SetPVarInt(playerid,  "BLOCKED", 3);
				if(VehicleInfo[VehID][vEngine] == 0)
				{
               		SetVehicleParamsEx(VehID,VEHICLE_PARAMS_ON,light,alarm,doors,bonnet,boot,objective);
	           		new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
               		format(str, sizeof(str), "%s attempts to start %s engine.", PlayerName, VehicleName );
	           		SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
               		format(str, sizeof(str), "%s engine starts (( %s ))", VehicleName, PlayerName );
	           		SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
	           		VehicleInfo[VehID][vEngine] = 1;
	           		UpdateVehicleCPU(playerid);
	           		return true;
				}
				else
				{
	               SetVehicleParamsEx(VehID,VEHICLE_PARAMS_OFF,light,alarm,doors,bonnet,boot,objective);
		           new VehicleName[24];
	   	           GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	               format(str, sizeof(str), "%s turns off %s's engine.", PlayerName, VehicleName );
		           SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		           VehicleInfo[VehID][vEngine] = 0;
		           UpdateVehicleCPU(playerid);
		           return true;
				}
			 }
            if(lr < 0)
            {
                SetPVarInt(playerid,  "BLOCKED", 3);
				if(VehicleInfo[VehID][vEngine] == 0)
				{
	               SetVehicleParamsEx(VehID,VEHICLE_PARAMS_ON,light,alarm,doors,bonnet,boot,objective);
		           new VehicleName[24];
	   	           GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	               format(str, sizeof(str), "%s attempts to start %s engine.", PlayerName, VehicleName );
		           SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
	               format(str, sizeof(str), "%s engine starts (( %s ))", VehicleName, PlayerName );
		           SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		           VehicleInfo[VehID][vEngine] = 1;
		           UpdateVehicleCPU(playerid);
		           return true;
				}
				else
				{
	               SetVehicleParamsEx(VehID,VEHICLE_PARAMS_OFF,light,alarm,doors,bonnet,boot,objective);
		           new VehicleName[24];
	   	           GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	               format(str, sizeof(str), "%s turns off %s's engine.", PlayerName, VehicleName );
		           SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		           VehicleInfo[VehID][vEngine] = 0;
		           UpdateVehicleCPU(playerid);
		           return true;
				}
			}
	    }
        if(GetPVarInt(playerid, "VEHICLE_OPTION") == 2)
        {
		     if(lr > 0)
	         {
                 SetPVarInt(playerid,  "BLOCKED", 3);
				 if(light == -1 || light == 0)
				 {
                    new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	                format(str, sizeof(str), "%s turns %s's lights on.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
					SetVehicleParamsEx(VehID,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
                  }
		         else
				 {
					new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
                    format(str, sizeof(str), "%s turns %s's lights off.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
					SetVehicleParamsEx(VehID,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
				 }
                 UpdateVehicleCPU(playerid);
                 return true;
			 }
		     if(lr < 0)
	         {
                 SetPVarInt(playerid,  "BLOCKED", 3);
				 if(light == -1 || light == 0)
				 {
                    new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	                format(str, sizeof(str), "%s turns %s's lights on.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
					SetVehicleParamsEx(VehID,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
                  }
		         else
				 {
					new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
                    format(str, sizeof(str), "%s turns %s's lights off.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
					SetVehicleParamsEx(VehID,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
                 }
                 UpdateVehicleCPU(playerid);
                 return true;
			 }
	    }
        if(GetPVarInt(playerid, "VEHICLE_OPTION") == 3)
        {

		     if(lr > 0)
	         {
				 if(VehicleInfo[VehID][vOwner] != PlayerInfo[playerid][cSQLID] && VehicleInfo[VehID][vRented] != PlayerInfo[playerid][cSQLID]) return SendClientMessage(playerid, COLOR_GREY, "You don't have keys for this vehicle");
                 SetPVarInt(playerid,  "BLOCKED", 3);
				 if(VehicleInfo[VehID][vLock] == 0)
				 {
                    new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	                format(str, sizeof(str), "%s locks %s's doors.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		            VehicleInfo[VehID][vLock] = 1;
		            SetVehicleParamsEx(VehID,engine,light,alarm,VEHICLE_PARAMS_ON,bonnet,boot,objective);
	    		 }
	    		 else
	    		 {
                    new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	                format(str, sizeof(str), "%s unlocks %s's doors.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		            VehicleInfo[VehID][vLock] = 0;
		            SetVehicleParamsEx(VehID,engine,light,alarm,VEHICLE_PARAMS_OFF,bonnet,boot,objective);
	    		 }
			 }
		     if(lr < 0)
	         {
				 if(VehicleInfo[VehID][vOwner] != PlayerInfo[playerid][cSQLID] && VehicleInfo[VehID][vRented] != PlayerInfo[playerid][cSQLID]) return SendClientMessage(playerid, COLOR_GREY, "You don't have keys for this vehicle");
                 SetPVarInt(playerid,  "BLOCKED", 3);
				 if(VehicleInfo[VehID][vLock] == 0)
				 {
                    new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	                format(str, sizeof(str), "%s locks %s's doors.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		            VehicleInfo[VehID][vLock] = 1;
		            SetVehicleParamsEx(VehID,engine,light,alarm,VEHICLE_PARAMS_ON,bonnet,boot,objective);
	    		 }
	    		 else
	    		 {
                    new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	                format(str, sizeof(str), "%s unlocks %s's doors.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		            VehicleInfo[VehID][vLock] = 0;
		            SetVehicleParamsEx(VehID,engine,light,alarm,VEHICLE_PARAMS_OFF,bonnet,boot,objective);
	    		 }
			 }
 		     UpdateVehicleCPU(playerid);
 		     return true;
		 }
        if(GetPVarInt(playerid, "VEHICLE_OPTION") == 4)
        {

		     if(lr > 0)
	         {
                 SetPVarInt(playerid,  "BLOCKED", 3);
				 if(bonnet == 0 || bonnet == -1)
				 {
                    new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	                format(str, sizeof(str), "%s opens %s's trunk.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		            SetVehicleParamsEx(VehID,engine,light,alarm,doors,VEHICLE_PARAMS_ON,boot,objective);
	    		 }
	    		 else
	    		 {
                    new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	                format(str, sizeof(str), "%s closes %s's trunk.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		            SetVehicleParamsEx(VehID,engine,light,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
	    		 }
			 }
		     if(lr < 0)
	         {
                 SetPVarInt(playerid,  "BLOCKED", 3);
				 if(bonnet == 0 || bonnet == -1)
				 {
                    new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	                format(str, sizeof(str), "%s opens %s's trunk.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		            SetVehicleParamsEx(VehID,engine,light,alarm,doors,VEHICLE_PARAMS_ON,boot,objective);
	    		 }
	    		 else
	    		 {
                    new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	                format(str, sizeof(str), "%s closes %s's trunk.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		            SetVehicleParamsEx(VehID,engine,light,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
	    		 }
			 }
			 UpdateVehicleCPU(playerid);
			 return true;
		 }
        if(GetPVarInt(playerid, "VEHICLE_OPTION") == 5)
        {

		     if(lr > 0)
	         {
                 SetPVarInt(playerid,  "BLOCKED", 3);
				 if(boot == 0 || boot == -1)
				 {
                    new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	                format(str, sizeof(str), "%s opens %s's boot.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		            SetVehicleParamsEx(VehID,engine,light,alarm,doors,bonnet,VEHICLE_PARAMS_ON,objective);
	    		 }
	    		 else
	    		 {
                    new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	                format(str, sizeof(str), "%s closes %s's boot.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		            SetVehicleParamsEx(VehID,engine,light,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
	    		 }
			 }
		     if(lr < 0)
	         {
                 SetPVarInt(playerid,  "BLOCKED", 3);
				 if(boot == 0 || boot == -1)
				 {
                    new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	                format(str, sizeof(str), "%s opens %s's boot.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		            SetVehicleParamsEx(VehID,engine,light,alarm,doors,bonnet,VEHICLE_PARAMS_ON,objective);
	    		 }
	    		 else
	    		 {
                    new VehicleName[24];
   	           		GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
	                format(str, sizeof(str), "%s closes %s's boot.", PlayerName, VehicleName );
		            SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
		            SetVehicleParamsEx(VehID,engine,light,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
	    		 }
			 }
			 UpdateVehicleCPU(playerid);
			 return true;
		}
	}
	if(GetPVarInt(playerid, "VEHICLE_CPU") == 2)
    {
           new Keys,ud,lr;
           GetPlayerKeys(playerid,Keys,ud,lr);
		   new hid = GetPVarInt(playerid, "HOUSEE");
		   GetPlayerName(playerid, PlayerName, 24);
		   if(GetPVarInt(playerid, "VEHICLE_OPTION") == 1)
		   {
		      if(lr < 0)
			  {
					if(HouseInfo[hid][hLocked] == 1)
					{
                         format(str, sizeof(str), "%s unlocks house's doors.", PlayerName);
  			             SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
  			             HouseInfo[hid][hLocked] = 0;
            	 	     UpdateVehicleCPU(playerid);
            	 	     return true;
					}
					if(HouseInfo[hid][hLocked] == 0)
					{
                         format(str, sizeof(str), "%s locks house's doors.", PlayerName);
  			             SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
  			             HouseInfo[hid][hLocked] = 1;
            	 	     UpdateVehicleCPU(playerid);
            	 	     return true;
					}
			  }
		      if(lr > 0)
			  {
					if(HouseInfo[hid][hLocked] == 1)
					{
                         format(str, sizeof(str), "%s unlocks house's doors.", PlayerName);
  			             SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
  			             HouseInfo[hid][hLocked] = 0;
            	 	     UpdateVehicleCPU(playerid);
            	 	     return true;
					}
					if(HouseInfo[hid][hLocked] == 0)
					{
                         format(str, sizeof(str), "%s locks house's doors.", PlayerName);
  			             SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
  			             HouseInfo[hid][hLocked] = 1;
            	 	     UpdateVehicleCPU(playerid);
            	 	     return true;
					}
			  }
		   }
	       return true;
	 }
     return true;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
	{
		TextDrawDestroy(SpeedHud[playerid]);
		TextDrawDestroy(VehName[playerid]);
		SpeedHud[playerid] = Text:INVALID_TEXT_DRAW;
		VehName[playerid] = Text:INVALID_TEXT_DRAW;
	}
	if(oldstate == PLAYER_STATE_PASSENGER && newstate == PLAYER_STATE_ONFOOT)
	{
		TextDrawDestroy(SpeedHud[playerid]);
		TextDrawDestroy(VehName[playerid]);
		SpeedHud[playerid] = Text:INVALID_TEXT_DRAW;
		VehName[playerid] = Text:INVALID_TEXT_DRAW;
	}
    if(newstate == PLAYER_STATE_DRIVER)
	{
	      new    VehID = GetPlayerVehicleID(playerid);
	      if(VehicleInfo[VehID][vEngine] == 0)
	      {
			   SendClientMessage(playerid, COLOR_GREEN, "{FFFFFF}Vehicle engine is {FF0000}off{FFFFFF} press {00F52D}LMB{FFFFFF} or type {00F52D}/vcp{FFFFFF} to start the engine.");
		  }
          if(VehicleInfo[VehID][vbuyable] == 1) // buyable :)
	      {
			 new m_str[128];
			 new VehicleName[24];
             GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
			 format(m_str, 128, "{FFFD96}INFO:{FFFFFF} This %s is for sell, you can buy it for {00F52D}%s", VehicleName, FormatMoney(VehicleInfo[VehID][vprice]));
			 SendClientMessage(playerid, COLOR_YELLOW, m_str);
			 SendClientMessage(playerid, COLOR_YELLOW, "{FFFD96}HINT:{FFFFFF} If you want to buy this car, type {FFFD96} /buyvehicle{FFFFFF} to buy it.");
			 SetPVarInt(playerid, "IN_BUY", 1);
			 return 1;
		  }
		  if(VehicleInfo[VehID][vrent] > 0 && VehicleInfo[VehID][vRented] == -1)
		  {
			 new r_str[128];
			 new VehicleName[24];
             GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
			 format(r_str, 128, "{FFFFFF}You can rent this {FF0000}%s{FFFFFF} for {00F52D}%s", VehicleName, FormatMoney(VehicleInfo[VehID][vrent]));
			 ShowPlayerDialog(playerid, DIALOG_VEHICLE_RENT, DIALOG_STYLE_MSGBOX, "{FF0000}Rent a vehicle", r_str, "Rent", "Cancel");
			 return true;

		  }
	}
	return 1;
}
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!IsPlayerSpawned(playerid))  return format(str, sizeof(str), "{FF0000}ERROR: {00FF9D}You must spawn before using %s.", cmdtext), SendClientMessage(playerid, COLOR_WHITE, str);
    if(success == 0)  return 	format(str, sizeof(str), "Command {FF0000}%s{FFFFFF} not found, type {00F52D}/help{FFFFFF} for commands.", cmdtext), SendClientMessage(playerid, COLOR_WHITE, str);
    return true;
}

forward ONEMIN();
public ONEMIN( )
{
   UpdateClock();
}

forward ONESEC();
public ONESEC( )
{
  foreach(Player, playerid)
  {
        if(GetPVarInt(playerid, "InfoBar") > 0)
		{
            SetPVarInt(playerid, "InfoBar", GetPVarInt(playerid, "InfoBar") + 1);
            if(GetPVarInt(playerid, "InfoBar") == 2)
			{
				if(InfoBar[playerid] != Text:INVALID_TEXT_DRAW)
				{
	                TextDrawDestroy(InfoBar[playerid]);
	                InfoBar[playerid] = Text:INVALID_TEXT_DRAW;
				}
				if(InfoText[playerid] != Text:INVALID_TEXT_DRAW)
				{
                	TextDrawDestroy(InfoText[playerid]);
					InfoText[playerid] = Text:INVALID_TEXT_DRAW;
				}
                SetPVarInt(playerid, "InfoBar", 0);
                SetPVarInt(playerid, "INFO_SHOWING", 0);
            }
        }
        if(GetPVarInt(playerid, "IN_BUY") == 1)
        {
			 static info_str[128];
             static VehicleName[24];
			 new VehID = GetPlayerVehicleID(playerid);
             GetVehicleName(VehicleInfo[VehID][vModel], VehicleName, 24);
			 format(info_str, 128, "~y~Vehicle for sell~n~~n~~w~%s~n~Price:~y~%s", VehicleName, FormatMoney(VehicleInfo[VehID][vprice]));
			 ShowInfo2(playerid, info_str);
		}
        if(IsPlayerInAnyVehicle(playerid)) { continue; }
        foreach(Buildings, bb)
		{
            if(IsPlayerInRangeOfPoint(playerid, 3.0, BuildingInfo[bb][bbPos][0], BuildingInfo[bb][bbPos][1], BuildingInfo[bb][bbPos][2]))
			{
				  OnPlayerHitBuildingEntrance(playerid, bb);
            }
        }
		foreach(House, h)
		{
            if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ]))
			{
                  OnPlayerHitHouseEntrance(playerid, h);
			}
		}
		foreach(Businesses, bbid)
		{
            if(IsPlayerInRangeOfPoint(playerid, 2, BusinessInfo[bbid][bcoords][0], BusinessInfo[bbid][bcoords][1], BusinessInfo[bbid][bcoords][2]))
			{
				new b_str[150];
				new t_str[24];
				switch(BusinessInfo[bbid][btype])
				{
					 case 1: t_str = "Weapons";
					 case 2: t_str = "Store";
					 case 3: t_str = "Bar/Club";
					 case 4: t_str = "Electronics";
					 case 5: t_str = "Gym";
				}
				ShowInfo(playerid, "PRESS ~y~ALT~w~ TO ENTER");
				if(BusinessInfo[bbid][bowner] == 0)
				{
				   format(b_str, 150, "~g~Business for sale~n~~n~~y~%s~n~~w~Price: ~p~%s~n~~w~Type: ~p~%s",BusinessInfo[bbid][bname], FormatMoney(BusinessInfo[bbid][bprice]), t_str);
				   ShowInfo2(playerid, b_str);
				}
				else
				{
				   format(b_str, 150, "~y~Owned Business~n~~n~~p~%s~n~~w~Owner: ~y~%s", BusinessInfo[bbid][bname], GetUserDBName(BusinessInfo[bbid][bowner]));
				   ShowInfo2(playerid, b_str);
				}
			}
		}
   }
}

forward MILSEC();
public MILSEC( )
{
  foreach(Player, playerid)
  {
	 if(IsPlayerInAnyVehicle(playerid))
	 {
		 new VehID = GetPlayerVehicleID(playerid);
		 if(VehicleInfo[VehID][vEngine] == 1)
		 {
			   UpdateSpeedo(playerid, VehID);
	     }
	 }
	 if(GetPVarInt(playerid, "BLOCKED") > 0)
	 {
		 SetPVarInt(playerid,  "BLOCKED", GetPVarInt(playerid, "BLOCKED") -1);
	 }
   }
}

forward LoginScreen2(playerid);
public LoginScreen2(playerid)
{
    Camera[playerid] += 0.4;
    SetPlayerCameraPos(playerid,1709.7380,Camera[playerid],101.5374);
    SetPlayerCameraLookAt(playerid,1642.6224,-1200.3054,119.3296);
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	   DeletePVar(playerid, "IN_BUY");
}

public OnPlayerUseItem(playerid,ItemName[])
{
	// WEAPONS
    if(!strcmp(ItemName,"9mm",true))
	{
		 RemoveItem(playerid, "9mm", 1);
		 GivePlayerWeapon(playerid, 22, 120);
         GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
         format(str, sizeof(str), "%s takes out his 9mm from inventory.", PlayerName);
         SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
         return true;
	}
    if(!strcmp(ItemName,"shotgun",true))
	{
		 RemoveItem(playerid, "shotgun", 1);
		 GivePlayerWeapon(playerid, 25, 120 / 2);
         GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
         format(str, sizeof(str), "%s takes out his shotgun from inventory.", PlayerName);
         SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
         return true;
	}
    if(!strcmp(ItemName,"body armour",true))
	{
		 RemoveItem(playerid, "body armour", 1);
		 SetPlayerArmour(playerid, 100);
         GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
         format(str, sizeof(str), "%s takes out his body armour from inventory and wears it.", PlayerName);
         SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
         return true;
	}
    if(!strcmp(ItemName,"Hunting Rifle",true))
	{
		 RemoveItem(playerid, "Hunting Rifle", 1);
		 GivePlayerWeapon(playerid, 33, 40);
         GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
         format(str, sizeof(str), "%s takes out his hunting rifle from inventory.", PlayerName);
         SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
         return true;
	}
	// DRINKS
    if(!strcmp(ItemName,"Beer",true))
	{
		 RemoveItem(playerid, "Beer", 1);
		 SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DRINK_BEER);
         GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
         format(str, sizeof(str), "%s takes out his beer bottle from inventory.", PlayerName);
         SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
         return true;
	}
    if(!strcmp(ItemName,"Wine",true))
	{
		 RemoveItem(playerid, "Wine", 1);
		 SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DRINK_WINE);
         GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
         format(str, sizeof(str), "%s takes out his wine bottle from inventory.", PlayerName);
         SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
         return true;
	}
    if(!strcmp(ItemName,"Vodka",true))
	{
		 RemoveItem(playerid, "Vodka", 1);
		 SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DRINK_WINE);
         GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
         format(str, sizeof(str), "%s takes out his vodka bottle from inventory.", PlayerName);
         SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
         return true;
	}
    if(!strcmp(ItemName,"Sprunk",true))
	{
		 RemoveItem(playerid, "Sprunk", 1);
		 SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DRINK_SPRUNK);
         GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
         format(str, sizeof(str), "%s takes out his sprunk bottle from inventory.", PlayerName);
         SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
         return true;
	}
    if(!strcmp(ItemName,"Laptop",true))
	{
         GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
         format(str, sizeof(str), "%s takes out his laptop from inventory and starts it.", PlayerName);
         SendLocalMessage(playerid, str, 20.0, 0x83bfbfAA);
         ShowPlayerDialog(playerid, LAPTOP_DIALOG, DIALOG_STYLE_LIST, "USER-Aker", "- Send E-Mail\n- Check E-Mail\n- Goto Adress\n- Create my website\n- Edit my website\n- Poogle", "Okay", "Shut Down");
         return true;
	}
    if(!strcmp(ItemName,"Walkie Talkie",true))
	{
		 new string[128];
		 format(string, 128, "{33CCFF}Current channel:{FFFFFF} %i\nType in channel you wish to set.", PlayerInfo[playerid][pRadio]);
		 ShowPlayerDialog(playerid, DIALOG_CONFIGURE_RADIO, DIALOG_STYLE_INPUT, "Walkie Talkie", string, "Configure", "Exit");
		 return true;
	}
    if(!strcmp(ItemName,"GPS",true))
	{
		mysql_query("SELECT Place FROM gps", THREAD_GPS_SHOW , playerid);
		return true;
	}
    if(!strcmp(ItemName,"Cellphone",true))
	{
		 new string[64];
		 format(string, 64, "{33CCFF}Phone number:{FFFFFF} %i", PlayerInfo[playerid][pNumber]);
		 ShowPlayerDialog(playerid,	DIALOG_PHONE_MENU, DIALOG_STYLE_LIST, string, "Call\nView Contacts\nSMS", "Select", "Close");
		 return true;
	}
	return true;
}

// PROFIT!!!!!!
